【精选】Java命令:jstat

您所在的位置:网站首页 win10查看内存使用情况 【精选】Java命令:jstat

【精选】Java命令:jstat

2023-10-26 10:25| 来源: 网络整理| 查看: 265

文章目录 一、简介二、常用命令1、jstat -class pid : class loader行为统计2、jstat -compiler pid : JIT编译器行为统计3、jstat -gc pid 5000 20 : 垃圾回收堆行为统计4、jstat -gccapacity pid 5000 20 : 堆内存统计5、jstat -gcutil pid 5000 20 : 总结垃圾回收统计6、jstat -gccause pid 5000 20 : 垃圾收集统计概述7、jstat -gcnew pid 5000 20 : 新生代垃圾回收统计8、jstat -gcnewcapacity pid 5000 20 : 新生代内存统计9、jstat -gcold pid 5000 20 : 老年代垃圾回收统计10、jstat -gcoldcapacity pid 5000 20 : 老年代内存统计11、jstat -gcmetacapacity pid 5000 20 : 元数据空间统计12、jstat -printcompilation pid : 编译方法统计

一、简介

jstat(JVM statistics Monitoring)命令主要是 对java应用程序的资源和性能进行实时的命令行监控,包括了对 heap size 和 垃圾回收状况 的监控。

jstat

输出结果:

root@yzh-zabbix-server:bin #jstat invalid argument count Usage: jstat -help|-options jstat - [-t] [-h] [ []] Definitions: An option reported by the -options option Virtual Machine Identifier. A vmid takes the following form: [@[:]] Where is the local vm identifier for the target Java virtual machine, typically a process id; is the name of the host running the target Java virtual machine; and 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. Number of samples between header lines. Sampling interval. The following forms are allowed: ["ms"|"s"] Where is an integer and the suffix specifies the units as milliseconds("ms") or seconds("s"). The default units are "ms". Number of samples to take before terminating. -J Pass directly to the runtime system.

命令格式:

jstat [option] vmid [interval] [count]

参数说明:

参数说明option操作参数,我们经常使用的选项有gc、gccapacity、gcnew、gcnewcapacity、gcold、gcoldcapacity、gcmetacapacity、gcutil等。vmidjava进程IDinterval间隔时间,单位为毫秒。count打印次数。

option参数总览:

参数说明classclass loader的行为统计。compilerHotSpot JIT编译器行为统计。gc垃圾回收堆的行为统计。gccapacity各个垃圾回收代容量(young、old、perm)和他们相应的空间统计。gcutil垃圾回收统计概述。gccause垃圾收集器概述。gcnew新生代行为统计。gcnewcapacity新生代与其相应的内存空间的统计。gcold老年代和永久代行为统计。gcoldcapacity老年代行为统计gcmetacapacity元数据区行为统计。printcompilationHotSpot编译方法统计。 二、常用命令 1、jstat -class pid : class loader行为统计

监视类装载、卸载数量、总空间以及耗费的时间

jstat -class pid

输出结果:

Loaded Bytes Unloaded Bytes Time 4995 10540.4 0 0.0 5.22

字段说明:

字段说明Loaded加载class的数量。Bytesclass字节大小。Unloaded未加载class的数量。Bytes未加载class的字节大小。Time加载时间。 2、jstat -compiler pid : JIT编译器行为统计

输出JIT编译过的方法数量耗时等。

jstat -compiler pid

输出结果:

Compiled Failed Invalid Time FailedType FailedMethod 3641 1 0 16.62 1 com/cloudwise/agent/deps/asm/ClassReader accept

字段说明:

字段说明Compiled编译数量。Failed编译失败数量。Invalid无效数量。Time编译耗时。FailedType失败类型。FailedMethod失败方法的全限定名。 3、jstat -gc pid 5000 20 : 垃圾回收堆行为统计

5秒钟打印一次,一共打印20次。

jstat -gc pid 5000 20

输出结果:

root@yzh-zabbix-server:bin #jstat -gc 3111 5000 20 S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT 14336.0 24576.0 0.0 0.0 50688.0 50687.9 330752.0 330634.8 55296.0 53462.8 6400.0 5925.3 178 2.226 2483 438.892 441.117 14336.0 24576.0 0.0 0.0 50688.0 50688.0 330752.0 330607.2 55296.0 53467.9 6400.0 5925.3 178 2.226 2511 443.944 446.169 14336.0 24576.0 0.0 0.0 50688.0 50686.3 330752.0 330591.4 55296.0 53467.9 6400.0 5925.3 178 2.226 2541 449.050 451.275 14336.0 24576.0 0.0 0.0 50688.0 50687.9 330752.0 330603.5 55296.0 53467.9 6400.0 5925.3 178 2.226 2569 454.029 456.255 14336.0 24576.0 0.0 0.0 50688.0 50688.0 330752.0 330607.6 55296.0 53467.9 6400.0 5925.3 178 2.226 2598 458.971 461.197

C 即 Capacity 总容量,U 即 Used 已使用的容量。

字段说明:

字段说明S0C年轻代第一个Survivor区的大小(字节)S1C年轻代第二个Survivor区的大小(字节)S0U年轻代第一个Survivor区的使用大小(字节)S1U年轻代第二个Survivor区的使用大小(字节)EC年轻代中Eden区的大小(字节)EU年轻代中Eden区的使用大小(字节)OC老年代大小(字节)OU老年代使用大小(字节)MC方法区大小(字节)MU方法区使用大小(字节)CCSC压缩类空间大小(字节)CCSU压缩类空间使用大小(字节)YGC年轻代垃圾回收次数YGCT年轻代垃圾回收消耗时间FGC老年代垃圾回收次数FGCT老年代垃圾回收消耗时间GCT垃圾回收消耗总时间 4、jstat -gccapacity pid 5000 20 : 堆内存统计

5秒钟打印一次,一共打印20次。

同 -gc ,不过还会输出 Java 堆各区域使用到的最大、最小空间。

jstat -gccapacity pid 5000 20

输出结果:

root@yzh-zabbix-server:bin #jstat -gccapacity 3111 5000 20 NGCMN NGCMX NGC S0C S1C EC OGCMN OGCMX OGC OC MCMN MCMX MC CCSMN CCSMX CCSC YGC FGC 10752.0 164864.0 110080.0 14336.0 24576.0 50688.0 22016.0 330752.0 330752.0 330752.0 0.0 1097728.0 55296.0 0.0 1048576.0 6400.0 178 7491 10752.0 164864.0 110080.0 14336.0 24576.0 50688.0 22016.0 330752.0 330752.0 330752.0 0.0 1097728.0 55296.0 0.0 1048576.0 6400.0 178 7520 10752.0 164864.0 110080.0 14336.0 24576.0 50688.0 22016.0 330752.0 330752.0 330752.0 0.0 1097728.0 55296.0 0.0 1048576.0 6400.0 178 7547

字段说明:

字段说明NGCMN新生代最小容量NGCMX新生代最大容量NGC当前新生代容量S0C第一个Survivor区大小S1C第二个Survivor区的大小ECEden区的大小OGCMN老年代最小容量OGCMX老年代最大容量OGC当前老年代大小OC当前老年代大小MCMN最小元数据容量MCMX最大元数据容量MC当前元数据空间大小CCSMN最小压缩类空间大小CCSMX最大压缩类空间大小CCSC当前压缩类空间大小YGC年轻代gc次数FGC老年代GC次数 5、jstat -gcutil pid 5000 20 : 总结垃圾回收统计

5秒钟打印一次,一共打印20次。

同 -gc ,不过输出的是已使用空间占总空间的百分比

jstat -gcutil pid 5000 20

输出结果:

root@yzh-zabbix-server:bin #jstat -gcutil 3111 5000 20 S0 S1 E O M CCS YGC YGCT FGC FGCT GCT 0.00 0.00 100.00 99.95 96.75 92.57 178 2.226 10172 1772.566 1774.791 0.00 0.00 100.00 99.95 96.75 92.57 178 2.226 10203 1777.589 1779.814 0.00 0.00 100.00 99.95 96.75 92.57 178 2.226 10234 1782.580 1784.806

字段说明:

字段说明S0第一个Servivor区当前使用比例S1第二个Servivor区当前使用比例EEden区使用比例O老年代使用比例M元数据区使用比例CCS压缩使用比例YGC年轻代垃圾回收次数FGC老年代垃圾回收次数FGCT老年代垃圾回收消耗时间GCT垃圾回收消耗总时间 6、jstat -gccause pid 5000 20 : 垃圾收集统计概述

5秒钟打印一次,一共打印20次。

同 -gcutil ,附加最近两次垃圾回收事件的原因。

jstat -gccause pid 5000 20

输出结果:

S0 S1 E O M CCS YGC YGCT FGC FGCT GCT LGCC GCC 0.00 0.00 35.78 19.43 97.96 95.19 20 0.176 11 0.406 0.582 Heap Inspection Initiated GC No GC

字段说明:

字段说明S0第一个Servivor区当前使用比例S1第二个Servivor区当前使用比例EEden区使用比例O老年代使用比例M元数据区使用比例CCS压缩使用比例YGC年轻代垃圾回收次数FGC老年代垃圾回收次数FGCT老年代垃圾回收消耗时间GCT垃圾回收消耗总时间LGCC最近垃圾回收的原因GCC当前垃圾回收的原因 7、jstat -gcnew pid 5000 20 : 新生代垃圾回收统计

5秒钟打印一次,一共打印20次。

jstat -gcnew pid 5000 20

输出结果:

root@yzh-zabbix-server:bin #jstat -gcnew 3111 5000 20 S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT 14336.0 24576.0 0.0 0.0 12 15 24576.0 50688.0 50688.0 178 2.226 14336.0 24576.0 0.0 0.0 12 15 24576.0 50688.0 50688.0 178 2.226 14336.0 24576.0 0.0 0.0 12 15 24576.0 50688.0 50688.0 178 2.226

字段说明:

字段说明S0C第一个Survivor区大小S1C第二个Survivor区的大小S0U第一个Survivor区的使用大小S1U第二个Survivor区的使用大小TT对象在新生代存活的次数MTT对象在新生代存活的最大次数DSS期望的Survivor区大小ECEden区的大小EUEden区的使用大小YGC年轻代垃圾回收次数YGCT年轻代垃圾回收消耗时间 8、jstat -gcnewcapacity pid 5000 20 : 新生代内存统计

5秒钟打印一次,一共打印20次。

jstat -gcnewcapacity pid 5000 20

输出结果:

root@yzh-zabbix-server:bin #jstat -gcnewcapacity 3111 5000 20 NGCMN NGCMX NGC S0CMX S0C S1CMX S1C ECMX EC YGC FGC 10752.0 164864.0 110080.0 54784.0 14336.0 54784.0 24576.0 163840.0 50688.0 178 14824 10752.0 164864.0 110080.0 54784.0 14336.0 54784.0 24576.0 163840.0 50688.0 178 14850 10752.0 164864.0 110080.0 54784.0 14336.0 54784.0 24576.0 163840.0 50688.0 178 14878

字段说明:

字段说明NGCMN新生代最小容量NGCMX新生代最大容量NGC当前新生代容量S0CMX第一个Survivor区最大大小S0C第一个Survivor区当前大小S1CMX第二个Survivor区最大大小S1C第二个Survivor区当前大小ECMXEden区最大大小ECEden区当前大小YGC年轻代垃圾回收次数FGC老年代回收次数 9、jstat -gcold pid 5000 20 : 老年代垃圾回收统计

5秒钟打印一次,一共打印20次。

jstat -gcold pid 5000 20

输出结果:

root@yzh-zabbix-server:bin #jstat -gcold 3111 5000 20 MC MU CCSC CCSU OC OU YGC FGC FGCT GCT 55552.0 53550.5 6400.0 5924.5 330752.0 330602.1 178 16635 2895.316 2897.541 55552.0 53550.5 6400.0 5924.5 330752.0 330601.3 178 16665 2900.278 2902.504 55552.0 53550.5 6400.0 5924.5 330752.0 330604.3 178 16693 2905.210 2907.435

字段说明:

字段说明MC方法区大小MU方法区使用大小CCSC压缩类空间大小CCSU压缩类空间使用大小OC老年代大小OU老年代使用大小YGC年轻代垃圾回收次数FGC老年代垃圾回收次数FGCT老年代垃圾回收消耗时间GCT垃圾回收消耗总时间 10、jstat -gcoldcapacity pid 5000 20 : 老年代内存统计

5秒钟打印一次,一共打印20次。

jstat -gcoldcapacity pid 5000 20

输出结果:

root@yzh-zabbix-server:bin #jstat -gcoldcapacity 3111 5000 20 OGCMN OGCMX OGC OC YGC FGC FGCT GCT 22016.0 330752.0 330752.0 330752.0 178 17810 3099.915 3102.140 22016.0 330752.0 330752.0 330752.0 178 17840 3104.912 3107.137 22016.0 330752.0 330752.0 330752.0 178 17870 3109.847 3112.073

字段说明:

字段说明OGCMN老年代最小容量OGCMX老年代最大容量OGC当前老年代大小OC老年代大小YGC年轻代垃圾回收次数FGC老年代垃圾回收次数FGCT老年代垃圾回收消耗时间GCT垃圾回收消耗总时间 11、jstat -gcmetacapacity pid 5000 20 : 元数据空间统计

5秒钟打印一次,一共打印20次。

jstat -gcmetacapacity pid 5000 20

输出结果:

root@yzh-zabbix-server:bin #jstat -gcmetacapacity 3111 5000 20 MCMN MCMX MC CCSMN CCSMX CCSC YGC FGC FGCT GCT 0.0 1097728.0 55552.0 0.0 1048576.0 6400.0 178 18795 3270.543 3272.768 0.0 1097728.0 55552.0 0.0 1048576.0 6400.0 178 18824 3275.425 3277.650 0.0 1097728.0 55552.0 0.0 1048576.0 6400.0 178 18853 3280.369 3282.595

字段说明:

字段说明MCMN最小元数据容量MCMX最大元数据容量MC当前元数据空间大小CCSMN最小压缩类空间大小CCSMX最大压缩类空间大小CCSC当前压缩类空间大小YGC年轻代垃圾回收次数FGC老年代垃圾回收次数FGCT老年代垃圾回收消耗时间GCT垃圾回收消耗总时间 12、jstat -printcompilation pid : 编译方法统计 jstat -printcompilation -pid

输出结果:

Compiled Size Type Method 3745 8 1 java/lang/Long toString

字段说明:

字段说明Compiled被执行的编译任务的数量Size方法字节码的字节数Type编译类型Method编译方法的类名和方法名。类名使用"/" 代替 “.” 作为空间分隔符. 方法名是给出类的方法名. 格式是一致于HotSpot - XX:+PrintComplation 选项



【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3