JVM在线分析-监控工具(jps,jstat,jstatd)
- 电脑硬件
- 2025-08-13 04:30:02

参考官方文档(jdk11) docs.oracle /en/java/javase/11/tools/troubleshooting-tools-and-commands.html#GUID-CB44BFBA-E5F9-4D80-8EE8-28E9F16BC451
1. 监控工具(jps, jstat, jstatd) jps -q Suppresses the output of the class name, JAR file name, and arguments passed to the main method, producing a list of only local JVM identifiers. -mlvV -m displays the arguments passed to the main method. The output may be null for embedded JVMs. -l displays the full package name for the application's main class or the full path name to the application's JAR file. -v displays the arguments passed to the JVM. -V suppresses the output of the class name, JAR file name, and arguments passed to the main method, producing a list of only local JVM identifiers. jstat (base) PS C:\Users\zishi> jstat -h Usage: jstat --help|-options jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]] Definitions: <option> An option reported by the -options option <vmid> Virtual Machine Identifier. A vmid takes the following form: <lvmid>[@<hostname>[:<port>]] Where <lvmid> is the local vm identifier for the target Java virtual machine, typically a process id; <hostname> is the name of the host running the target Java virtual machine; and <port> is the port number for the rmiregistry on the target host. See the jvmstat documentation for a more complete description of the Virtual Machine Identifier. <lines> Number of samples between header lines. <interval> Sampling interval. The following forms are allowed: <n>["ms"|"s"] Where <n> is an integer and the suffix specifies the units as milliseconds("ms") or seconds("s"). The default units are "ms". <count> Number of samples to take before terminating. -J<flag> Pass <flag> directly to the runtime system. -? -h --help Prints this help message. -help Prints this help message.说明:
option:参数选项 -t:可以在打印的列加上Timestamp列,用于显示系统运行的时间 -h:可以在周期性数据输出的时候,指定输出多少行以后输出一次表头 vmid:Virtual Machine ID( 进程的 pid) interval:执行每次的间隔时间,单位为毫秒 count:用于指定输出多少次记录,缺省则会一直打印
示例:
(base) PS C:\Users\zishi> jstat -gcutil -t -h5 24392 1000 20 Timestamp S0 S1 E O M CCS YGC YGCT FGC FGCT CGC CGCT GCT 2587.6 0.00 100.00 14.61 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 2588.6 0.00 100.00 14.61 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 2589.6 0.00 100.00 14.61 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 2590.7 0.00 100.00 14.61 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 2591.7 0.00 100.00 14.61 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 Timestamp S0 S1 E O M CCS YGC YGCT FGC FGCT CGC CGCT GCT 2592.7 0.00 100.00 14.61 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 2593.7 0.00 100.00 14.61 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 2594.7 0.00 100.00 14.61 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 2595.7 0.00 100.00 14.61 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 2596.7 0.00 100.00 14.61 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 Timestamp S0 S1 E O M CCS YGC YGCT FGC FGCT CGC CGCT GCT 2597.7 0.00 100.00 14.61 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 2598.7 0.00 100.00 14.61 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 2599.7 0.00 100.00 14.61 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 2600.7 0.00 100.00 14.61 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 2601.7 0.00 100.00 14.61 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 Timestamp S0 S1 E O M CCS YGC YGCT FGC FGCT CGC CGCT GCT 2602.8 0.00 100.00 14.61 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 2603.8 0.00 100.00 14.61 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 2604.8 0.00 100.00 15.17 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 2605.8 0.00 100.00 15.17 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212 2606.8 0.00 100.00 15.17 11.16 97.36 91.49 12 0.202 0 0.000 6 0.010 0.212-options说明
(base) PS C:\Users\zishi> jstat -options -class -compiler -gc -gccapacity -gccause -gcmetacapacity -gcnew -gcnewcapacity -gcold -gcoldcapacity -gcutil -printcompilationclass: Displays statistics about the behavior of the class loader.
(base) PS C:\Users\zishi> jstat -class 24392 Loaded Bytes Unloaded Bytes Time 13370 25776.4 0 0.0 6.23说明:
Loaded:加载class的数量 Bytes:所占用空间大小 Unloaded:未加载数量 Bytes:未加载占用空间 Time:时间
compiler: Displays statistics about the behavior of the Java HotSpot VM Just-in-Time compiler.
(base) PS C:\Users\zishi> jstat -compiler 24392 Compiled Failed Invalid Time FailedType FailedMethod 9892 1 0 52.28 1 org/springframework/cglib/core/MethodWrapper$MethodWrapperKey$$KeyFactoryByCGLIB$$552be97a hashCode说明:
Compiled:编译数量。 Failed:失败数量 Invalid:不可用数量 Time:时间 FailedType:失败类型 FailedMethod:失败的方法
gc: Displays statistics about the behavior of the garbage collected heap.
(base) PS C:\Users\zishi> jstat -gc 24392 S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT CGC CGCT GCT 0.0 36864.0 0.0 36864.0 358400.0 309248.0 231424.0 14005.6 73932.0 72017.7 8704.0 7939.9 11 0.185 0 0.000 6 0.010 0.195说明:
S0C:第一个幸存区的大小 S1C:第二个幸存区的大小 S0U:第一个幸存区的使用大小 S1U:第二个幸存区的使用大小 EC:eden区的大小 EU:eden区的使用大小 OC:老年代大小 OU:老年代使用大小 MC:方法区大小 MU:方法区使用大小 CCSC:压缩类空间大小 CCSU:压缩类空间使用大小 YGC:年轻代垃圾回收次数 YGCT:年轻代垃圾回收消耗时间 FGC:老年代垃圾回收次数 FGCT:老年代垃圾回收消耗时间 GCT:垃圾回收消耗总时间
gccapacity: Displays statistics about the capacities of the generations and their corresponding spaces.
(base) PS C:\Users\zishi> jstat -gccapacity 24392 NGCMN NGCMX NGC S0C S1C EC OGCMN OGCMX OGC OC MCMN MCMX MC CCSMN CCSMX CCSC YGC FGC CGC 0.0 8325120.0 395264.0 0.0 36864.0 358400.0 0.0 8325120.0 231424.0 231424.0 0.0 1114112.0 73932.0 0.0 1048576.0 8704.0 11 0 6NGCMN:新生代最小容量 NGCMX:新生代最大容量 NGC:当前新生代容量 S0C:第一个幸存区大小 S1C:第二个幸存区的大小 EC:伊甸园区的大小 OGCMN:老年代最小容量 OGCMX:老年代最大容量 OGC:当前老年代大小 OC:当前老年代大小 MCMN:最小元数据容量 MCMX:最大元数据容量 MC:当前元数据空间大小 CCSMN:最小压缩类空间大小 CCSMX:最大压缩类空间大小 CCSC:当前压缩类空间大小 YGC:年轻代gc次数 FGC:老年代GC次数
gccause: Displays a summary about garbage collection statistics (same as -gcutil), with the cause of the last and current (when applicable) garbage collection events.
(base) PS C:\Users\zishi> jstat -gccause 24392 S0 S1 E O M CCS YGC YGCT FGC FGCT CGC CGCT GCT LGCC GCC 0.00 100.00 89.14 6.05 97.41 91.22 11 0.185 0 0.000 6 0.010 0.195 G1 Evacuation Pause No GC说明:
这里是引用
gcnew: Displays statistics about the behavior of the new generation.
(base) PS C:\Users\zishi> jstat -gcnew 24392 S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT 0.0 36864.0 0.0 36864.0 7 15 23552.0 358400.0 323584.0 11 0.185说明:
S0C:第一个幸存区大小 S1C:第二个幸存区的大小 S0U:第一个幸存区的使用大小 S1U:第二个幸存区的使用大小 TT:对象在新生代存活的次数 MTT:对象在新生代存活的最大次数 DSS:期望的幸存区大小 EC:伊甸园区的大小 EU:伊甸园区的使用大小 YGC:年轻代垃圾回收次数 YGCT:年轻代垃圾回收消耗时间
gcnewcapacity: Displays statistics about the sizes of the new generations and their corresponding spaces.
(base) PS C:\Users\zishi> jstat -gcnewcapacity 24392 NGCMN NGCMX NGC S0CMX S0C S1CMX S1C ECMX EC YGC FGC CGC 0.0 8325120.0 395264.0 0.0 0.0 8325120.0 36864.0 8325120.0 358400.0 11 0 6说明:
NGCMN:新生代最小容量 NGCMX:新生代最大容量 NGC:当前新生代容量 S0CMX:最大幸存1区大小 S0C:当前幸存1区大小 S1CMX:最大幸存2区大小 S1C:当前幸存2区大小 ECMX:最大伊甸园区大小 EC:当前伊甸园区大小 YGC:年轻代垃圾回收次数 FGC:老年代回收次数
gcold: Displays statistics about the behavior of the old generation and metaspace statistics.
(base) PS C:\Users\zishi> jstat -gcold 24392 MC MU CCSC CCSU OC OU YGC FGC FGCT CGC CGCT GCT 73932.0 72017.7 8704.0 7939.9 231424.0 14005.6 11 0 0.000 6 0.010 0.195说明:
MC:方法区大小 MU:方法区使用大小 CCSC:压缩类空间大小 CCSU:压缩类空间使用大小 OC:老年代大小 OU:老年代使用大小 YGC:年轻代垃圾回收次数 FGC:老年代垃圾回收次数 FGCT:老年代垃圾回收消耗时间 GCT:垃圾回收消耗总时间
gcoldcapacity: Displays statistics about the sizes of the old generation.
(base) PS C:\Users\zishi> jstat -gcoldcapacity 24392 OGCMN OGCMX OGC OC YGC FGC FGCT CGC CGCT GCT 0.0 8325120.0 231424.0 231424.0 11 0 0.000 6 0.010 0.195说明:
OGCMN:老年代最小容量 OGCMX:老年代最大容量 OGC:当前老年代大小 OC:老年代大小 YGC:年轻代垃圾回收次数 FGC:老年代垃圾回收次数 FGCT:老年代垃圾回收消耗时间 GCT:垃圾回收消耗总时间
gcmetacapacity: Displays statistics about the sizes of the metaspace.
(base) PS C:\Users\zishi> jstat -gcmetacapacity 24392 MCMN MCMX MC CCSMN CCSMX CCSC YGC FGC FGCT CGC CGCT GCT 0.0 1114112.0 73932.0 0.0 1048576.0 8704.0 11 0 0.000 6 0.010 0.195说明:
MCMN:最小元数据容量 MCMX:最大元数据容量 MC:当前元数据空间大小 CCSMN:最小压缩类空间大小 CCSMX:最大压缩类空间大小 CCSC:当前压缩类空间大小 YGC:年轻代垃圾回收次数 FGC:老年代垃圾回收次数 FGCT:老年代垃圾回收消耗时间 GCT:垃圾回收消耗总时间
gcutil: Displays a summary about garbage collection statistics.
(base) PS C:\Users\zishi> jstat -gcutil 24392 S0 S1 E O M CCS YGC YGCT FGC FGCT CGC CGCT GCT 0.00 100.00 92.57 6.05 97.41 91.22 11 0.185 0 0.000 6 0.010 0.195说明:
S0:幸存1区当前使用比例 S1:幸存2区当前使用比例 E:伊甸园区使用比例 O:老年代使用比例 M:元数据区使用比例 CCS:压缩使用比例 YGC:年轻代垃圾回收次数 FGC:老年代垃圾回收次数 FGCT:老年代垃圾回收消耗时间 GCT:垃圾回收消耗总时间
printcompilation: Displays Java HotSpot VM compilation method statistics.
(base) PS C:\Users\zishi> jstat -printcompilation 24392 Compiled Size Type Method 10271 246 1 java/util/AbstractCollection toString说明:
Compiled:最近编译方法的数量 Size:最近编译方法的字节码数量 Type:最近编译方法的编译类型。 Method:方法名标识。
参考: docs.oracle /en/java/javase/11/tools/jstat.html#GUID-5F72A7F9-5D5A-4486-8201-E1D1BA8ACCB5
jstatd待完善 docs.oracle /en/java/javase/11/tools/jstatd.html#GUID-FA737806-75CD-4EE7-A087-1CC4A5441870
JVM在线分析-监控工具(jps,jstat,jstatd)由讯客互联电脑硬件栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“JVM在线分析-监控工具(jps,jstat,jstatd)”
上一篇
CPS:实现销售和广告的完美结合
下一篇
数据存储_PGSQL