jdk版本1.8.0_191
总览
名称 | 主要作用 |
---|---|
jps | JVM process status tool,显示所有java进程。 |
jstat | JVM statistics Monitoring Tool,用于收集虚拟机各方面的运行数据。 |
jinfo | Configuration info for java,现实虚拟机配置信息。 |
jmap | memory map for java,生成虚拟机的内存转储快照heapdump文件。 |
jhat | JVM Heap Dump Browser,分析heapdump文件。 |
jstack | stack trace for java,用于生成虚拟机的线程快照。 |
jcmd | 用于向 JVM 发送诊断命令请求。 |
帮助命令
--help
-h
> jps --help
> jps -h
jps
参数 | 作用 |
---|---|
-m | 输出虚拟机进程启动时传递给主类main函数的参数 |
-l | 输出主类的全名,如果进程执行的是JAR包,则输出JAR路径 |
-v | 输出虚拟机进程启动时的JVM参数 |
> jps -l
15472 org.jetbrains.jps.cmdline.Launcher
30528 org.jetbrains.jps.cmdline.Launcher
1556 jdk.jcmd/sun.tools.jps.Jps
27460 org.jetbrains.idea.maven.server.RemoteMavenServer36
31660 org.jetbrains.jps.cmdline.Launcher
jstat
参数 | 作用 |
---|---|
-gc | 监视java堆状态,包括Eden区,两个Survivor区,老年代,永久代的容量,已用空间,垃圾收集时间合计等信息。 |
-gccapacity | 与-gc相似,主要关注 各个区域使用到的最大,最小空间。 |
-gcutil | 与-gc相似,主要关注占比 |
> jstat -gc 26760 500 5
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT CGC CGCT GCT
9216.0 32768.0 8790.2 0.0 574976.0 132936.9 259584.0 82668.0 109772.0 104488.3 13824.0 12871.9 20 1.259 4 0.334 - - 1.594
9216.0 32768.0 8790.2 0.0 574976.0 132936.9 259584.0 82668.0 109772.0 104488.3 13824.0 12871.9 20 1.259 4 0.334 - - 1.594
9216.0 32768.0 8790.2 0.0 574976.0 132936.9 259584.0 82668.0 109772.0 104488.3 13824.0 12871.9 20 1.259 4 0.334 - - 1.594
9216.0 32768.0 8790.2 0.0 574976.0 132936.9 259584.0 82668.0 109772.0 104488.3 13824.0 12871.9 20 1.259 4 0.334 - - 1.594
9216.0 32768.0 8790.2 0.0 574976.0 132936.9 259584.0 82668.0 109772.0 104488.3 13824.0 12871.9 20 1.259 4 0.334 - - 1.594
S0C: 当前Survivor0的容量 (kB).
S1C: 当前Survivor1的容量(kB).
S0U: Survivor0已用内存 (kB).
S1U:Survivor1已用内存 (kB).
EC: Eden区容量 (kB).
EU: Eden区已用内存 (kB).
OC: 当前Old区容量 (kB).
OU: Old区已用内存 (kB).
MC: MetaSpace区容量 (kB).
MU: MetaSpace区已用内存 (kB).
CCSC: 类压缩区容量 (kB).
CCSU: 类压缩区已用内存 (kB).
YGC: 新生垃圾回收事件数量.
YGCT: 新生垃圾回收时间.
FGC: 垃圾回收事件总和.
FGCT: 完整的一次垃圾回收时间.
GCT: 所有的垃圾回收时间.
jinfo
> jinfo -h
Usage:
jinfo <option> <pid>
(to connect to a running process)
where <option> is one of:
-flag <name> to print the value of the named VM flag
-flag [+|-]<name> to enable or disable the named VM flag
-flag <name>=<value> to set the named VM flag to the given value
-flags to print VM flags
-sysprops to print Java system properties
<no option> to print both VM flags and system properties
-? | -h | --help | -help to print this help message
> jinfo -flags 26760
VM Flags:
-XX:CICompilerCount=4 -XX:InitialHeapSize=266338304 -XX:MaxHeapSize=4248829952 -XX:MaxNewSize=1416101888 -XX:MinHeapDeltaBytes=524288 -XX:NewSize=88604672 -XX:OldSize=177733632 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseFastUnorderedTimeStamps -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC
jmap
用于生成堆转储快照。
//生成快照
jmap -dump:live,format=b,file=heap.bin 20711
我本地 jmap -heap 会出现问题,可以看一下mac上 jmap命令 Can't attach symbolicator to the process
jhat
分析生成的快照。
一般把快照下载下来,使用其他工具分析,比如VisualVm,Eclipse Mermory Analyzer。
jstack
参数 | 作用 |
---|---|
-l | 除堆栈外,显示关于锁的附加信息。 |
jcmd
Jcmd 综合了前面的几个命令
> jcmd 21064 help
21064:
The following commands are available:
JFR.stop
JFR.start
JFR.dump
JFR.check
VM.native_memory
VM.check_commercial_features
VM.unlock_commercial_features
ManagementAgent.stop
ManagementAgent.start_local
ManagementAgent.start
VM.classloader_stats
GC.rotate_log
Thread.print
GC.class_stats
GC.class_histogram
GC.heap_dump
GC.finalizer_info
GC.heap_info
GC.run_finalization
GC.run
VM.uptime
VM.dynlibs
VM.flags
VM.system_properties
VM.command_line
VM.version
help
参考资料
oracle java8 jcmd
oracle java8 doc troubleshooting
java 11 jhsdb
网友评论