Day18-JDK中的多功能工具:jcmd(一)

jcmd介绍

jcmd是在JDK1.7之後新增的一项工具。它是一个多功能的工具,就想把瑞士刀一样,集合了各种小刀在同一把上。就用这篇来介绍jcmd可以达到什麽事情吧。

指令介绍

jcmd <pid | main class> <command ...|PerfCounter.print|-f file> 

or

jcmd <option>

若是想查看该指令的说明资讯,透过jcmd -hjcmd -help查看
https://ithelp.ithome.com.tw/upload/images/20211003/20140481Nlq0CGnkev.png
https://ithelp.ithome.com.tw/upload/images/20211003/20140481j1LZUwyjCX.png


  • jcmd

查看JVM进程的讯息
jcmd指令,就相当於jcmd -l以及jps -l
https://ithelp.ithome.com.tw/upload/images/20211003/20140481yVf98BUdLv.png

  • jcmd <pid> PerfCounter.print

查看指定进程的性能统计讯息
https://ithelp.ithome.com.tw/upload/images/20211003/20140481ipDlcuvcjy.jpg

  • jcmd <pid> help

针对指定进程,列出可使用的所有命令

以下的范例我用Day10-JDK查看虚拟机配置讯息工具:jinfo 这篇的范例进行程序的运行(Step1.~Step3.)
Step3.透过jps取得的进程是4221,以下示范的指令记得将4413改为欲查看的进程id喔!
https://ithelp.ithome.com.tw/upload/images/20211003/20140481ziXzQKDFKI.png

查出4221进程有以下命令可以使用
https://ithelp.ithome.com.tw/upload/images/20211003/201404815vdZzR45bh.png

  • jcmd <pid> 指定命令

显示指定进程的指定命令的数据或动作
根据上个指令查到的内容,我随便拿了其中一个命令进行演练,GC.class_histogram是查看系统中的类统计讯息
https://ithelp.ithome.com.tw/upload/images/20211003/2014048135KDKlMMls.jpg
查出的内容num总共有336,我只截取了前半部分


<<:  Day 18 : 笔记篇 05— 如何整理学习笔记?分享我的学习笔记整理流程

>>:  Angular 深入浅出三十天:表单与测试 Day18 - 与 Cypress 的初次见面(上)

DAY5 绘制介面

上一篇我们完成了wireframe的绘制,这次我们要将草稿跟库拉皮卡一样,没有办法下船更具现化一点,...

Day 8 进阶型别 - Part 1

今天要来介绍Intersection、Type guard。 Intersection 型别是把两种...

Material UI in React [ Day 7 ] Inputs (Button Group & Floating action button) & Styles

今天会接续Button的部分做个总结。 Button Group ButtonGroup 组件可用於...

Day 7 网路宝石:【Lab】VPC外网 Public Subnet to the Internet (IGW) (上)

今天我们要示范如何让一个在 Public Subnet 里面的 EC2 instance 可以与 ...

自动化 End-End 测试 Nightwatch.js 之踩雷笔记:上传档案II

如果上传档案不想使用 preload 档案,也不想用下载的方式,其实可以上传档案至 selenium...