JVM监控工具-jstat

jstat功能

查看虚拟机统计信息,主要分为三类:类加载、垃圾收集、即时编译。

用法

  • 命令格式
    jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]
  • 参数介绍
参数名介绍
option指定统计哪方面的JVM信息,可以通过jstat -options查看可选项
-t在输出信息第一列显示虚拟机启动时间
-h每隔多少行重新显示列标题(列名),防止显示行数太多后列标题就看不到了;-h5每5行重新显示标题
vmid虚拟机标识符,格式[protocol:][//]lvmid[@hostname[:port]/servername];如果监控本地虚拟机只提供lvmid(local vertual mechine identifier)即可
interval统计信息采样间隔,单位可以为sms,默认单位ms;1秒采样间隔可以表示为1s100ms1000
count采样次数,默认为正无穷大,直到命令终止或虚拟机终止才会退出
  • 统计选项
# 使用jstat -options查看option可选值
[root@localhost ~]# jstat -options
-class
-compiler
-gc
-gccapacity
-gccause
-gcmetacapacity
-gcnew
-gcnewcapacity
-gcold
-gcoldcapacity
-gcutil
-printcompilation

以上选项可以分为三类:

分类命令解释
类加载-class显示类加载器行为统计信息
即时编译-compiler显示解释编译统计信息,包括编译任务数、耗时、编译异常等
即时编译-printcompilation显示最新即时编译信息,包括类型、方法、大小等
垃圾回收-gc显示堆垃圾回收行为信息
垃圾回收-gcnew年轻代垃圾回收行为,较-gc增加TT、MTT、DSS三列
垃圾回收-gcold老年代垃圾回收行为,被-gc完全覆盖
垃圾回收-gccapacity显示各区域容量信息
垃圾回收-gcnewcapacity年轻代容量信息,较-gccapacity增加S0CMX、S1CMX、ECMX三列
垃圾回收-gcoldcapacity老年代容量信息,被-gccapacity完全覆盖
垃圾回收-gcmetacapacity元空间容量信息,被-gccapacity完全覆盖
垃圾回收-gcutil百分比形式展现垃圾收集汇总信息
垃圾回收-gccause-gcutil输出信息+上一次垃圾收集原因

实战

环境准备

启动一个tomcat服务器,用作被监控的Java进程。如果已有监控对象,可跳过此步骤。

# 查看当前路径
[root@localhost ~]# pwd
/root
# 下载一个tomcat
[root@localhost ~]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.50/bin/apache-tomcat-8.5.50.tar.gz
--2020-01-30 16:04:28--  https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.50/bin/apache-tomcat-8.5.50.tar.gz
正在解析主机 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
正在连接 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:10305939 (9.8M) [application/octet-stream]
正在保存至: “apache-tomcat-8.5.50.tar.gz”

100%[=========================================================>] 10,305,939  5.03MB/s 用时 2.0s   

2020-01-30 16:04:30 (5.03 MB/s) - 已保存 “apache-tomcat-8.5.50.tar.gz” [10305939/10305939])

# 解压tomcat 
[root@localhost ~]# tar -xf apache-tomcat-8.5.50.tar.gz 
# 启动tomcat
[root@localhost ~]# ./apache-tomcat-8.5.50/bin/startup.sh 
Using CATALINA_BASE:   /root/apache-tomcat-8.5.50
Using CATALINA_HOME:   /root/apache-tomcat-8.5.50
Using CATALINA_TMPDIR: /root/apache-tomcat-8.5.50/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /root/apache-tomcat-8.5.50/bin/bootstrap.jar:/root/apache-tomcat-8.5.50/bin/tomcat-juli.jar
Tomcat started.
# 通过jps命令查看是否启动成功,如下所示tomcat的lvmid为7654
[root@localhost ~]# jps -l
7810 sun.tools.jps.Jps
7654 org.apache.catalina.startup.Bootstrap

类加载-class

# 只显示一次类加载信息
[root@localhost ~]# jstat -class 7654
Loaded  Bytes  Unloaded  Bytes     Time   
  2410  4990.6        0     0.0       1.02
# 显示5次类加载信息,每秒1条
[root@localhost ~]# jstat -class 7654 1s 5
Loaded  Bytes  Unloaded  Bytes     Time   
  2410  4990.6        0     0.0       1.02
  2410  4990.6        0     0.0       1.02
  2410  4990.6        0     0.0       1.02
  2410  4990.6        0     0.0       1.02
  2410  4990.6        0     0.0       1.02
# 以2s/条显示5条统计信息,并显示虚拟机启动距今时间
[root@localhost ~]# jstat -class -t 7654 2s 5
Timestamp       Loaded  Bytes  Unloaded  Bytes     Time   
          796.5   2410  4990.6        0     0.0       1.02
          798.6   2410  4990.6        0     0.0       1.02
          800.6   2410  4990.6        0     0.0       1.02
          802.6   2410  4990.6        0     0.0       1.02
          804.6   2410  4990.6        0     0.0       1.02
# 以500ms/条速度显示10条,每隔5条显示一次表头
[root@localhost ~]# jstat -class -h5 7654 500 10
Loaded  Bytes  Unloaded  Bytes     Time   
  2410  4990.6        0     0.0       1.02
  2410  4990.6        0     0.0       1.02
  2410  4990.6        0     0.0       1.02
  2410  4990.6        0     0.0       1.02
  2410  4990.6        0     0.0       1.02
Loaded  Bytes  Unloaded  Bytes     Time   
  2410  4990.6        0     0.0       1.02
  2410  4990.6        0     0.0       1.02
  2410  4990.6        0     0.0       1.02
  2410  4990.6        0     0.0       1.02
  2410  4990.6        0     0.0       1.02  
  • 显示字段说明
    PerfCounter key: jcmd 7654 PerfCounter.print |grep java.cls.loadedClasses
    字段说明PerfCounter key
    Timestamp虚拟机启动距离现在时间,本例中804.6说明虚拟机已启动804.6秒
    Loaded已加载的类数量,本例中2410,表示已加载2410个类java.cls.loadedClasses
    Bytes已加载类的大小(KB),本例中为4990.6KBsun.cls.loadedBytes
    Unloaded已卸载类数量,本例中有0个已卸载的类java.cls.unloadedClasses
    Bytes已卸载类大小(KB),本例为0KBsun.cls.unloadedBytes
    Time加载和卸载类所花费的时间sun.cls.time

即时编译-compiler

# 显示一次即时编译信息
[root@localhost ~]# jstat -compiler 7654
Compiled Failed Invalid   Time   FailedType FailedMethod
    1914      1       0     3.19          1 org/apache/tomcat/util/IntrospectionUtils setProperty
# 以1s/条速率显示3次即时编译信息
[root@localhost ~]# jstat -compiler 7654 1s 3
Compiled Failed Invalid   Time   FailedType FailedMethod
    1917      1       0     3.20          1 org/apache/tomcat/util/IntrospectionUtils setProperty
    1917      1       0     3.20          1 org/apache/tomcat/util/IntrospectionUtils setProperty
    1917      1       0     3.20          1 org/apache/tomcat/util/IntrospectionUtils setProperty
  • 显示字段说明
    PerfCounter key: jcmd 7654 PerfCounter.print |grep sun.ci.totalCompiles

    字段说明PerfCounter key
    Compiled已执行的即时编译任务数,本例中执行了1917次即时编译任务sun.ci.totalCompiles
    Failed即时编译任务失败数,本例中有一个即时编译任务sun.ci.totalBailouts
    Invalid无效的即时编译任务数,本例中无时效编译任务sun.ci.totalInvalidates
    Time即时编译任务花费的时间,本例中即时编译花费3.2秒java.ci.totalTime
    FailedType上次编译失败的编译类型,本例中为1,也就是普通编译sun.ci.lastFailedType
    FailedMethod上次编译失败的类名.方法名,本例中为org/apache/tomcat/util/IntrospectionUtils类的setProperty方法sun.ci.lastFailedMethod
    编译类型:

    0:no_compile:没在编译
    1:normal_compile:普通编译(从方法正常入口开始编译)
    2:osr_compile:On-Stack Rreplacement编译(从方法中某个循环的回边开始编译)
    3:native_compile:native wrapper的编译

即时编译-printcompilation

# 输出最新的编译信息
[root@localhost ~]# jstat -printcompilation 7654
Compiled  Size  Type Method
    1980    346    1 java/util/regex/Pattern RemoveQEQuoting
# 每两秒输出一次最新的编译信息
[root@localhost ~]# jstat -printcompilation -t 7654 2s 1000
Timestamp       Compiled  Size  Type Method
         6431.6     1995    228    1 java/text/SimpleDateFormat encode
         6433.6     1995    228    1 java/text/SimpleDateFormat encode
    	.....
  • 显示字段说明
    PerfCounter key: jcmd 7654 PerfCounter.print |grep sun.ci.totalCompiles
    字段说明PerfCounter key
    Compiled截止上次编译已执行的编译任务数(与-compiler中一致),本例中执行了1995次即时编译任务sun.ci.totalCompiles
    Size上次编译方法的字节码大小,本例为228bsun.ci.lastSize
    Type上次时编译类型,本例为普通编译sun.ci.lastType
    Method删词即时编译方法,本例为java/text/SimpleDateFormat类的encode方法sun.ci.lastMethod

垃圾收集-gc

# 以1秒/次速度显示1000次gc信息,每显示10次后重新显示标题
[root@localhost ~]# jstat -gc -h10 7654 1s 1000
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT   
4608.0 1024.0  0.0   1008.0 32768.0  29610.6   20480.0    11614.8   16384.0 15835.8 1792.0 1605.2      5    0.056   0      0.000    0.056
4608.0 1024.0  0.0   1008.0 32768.0  29610.6   20480.0    11614.8   16384.0 15835.8 1792.0 1605.2      5    0.056   0      0.000    0.056
4608.0 1024.0  0.0   1008.0 32768.0  29610.6   20480.0    11614.8   16384.0 15835.8 1792.0 1605.2      5    0.056   0      0.000    0.056
4608.0 1024.0  0.0   1008.0 32768.0  29610.6   20480.0    11614.8   16384.0 15835.8 1792.0 1605.2      5    0.056   0      0.000    0.056
4608.0 1024.0  0.0   1008.0 32768.0  29610.6   20480.0    11614.8   16384.0 15835.8 1792.0 1605.2      5    0.056   0      0.000    0.056
4608.0 1024.0  0.0   1008.0 32768.0  29610.6   20480.0    11614.8   16384.0 15835.8 1792.0 1605.2      5    0.056   0      0.000    0.056
4608.0 1024.0  0.0   1008.0 32768.0  29610.6   20480.0    11614.8   16384.0 15835.8 1792.0 1605.2      5    0.056   0      0.000    0.056
4608.0 1024.0  0.0   1008.0 32768.0  29610.6   20480.0    11614.8   16384.0 15835.8 1792.0 1605.2      5    0.056   0      0.000    0.056
4608.0 1024.0  0.0   1008.0 32768.0  29610.6   20480.0    11614.8   16384.0 15835.8 1792.0 1605.2      5    0.056   0      0.000    0.056
4608.0 1024.0  0.0   1008.0 32768.0  29610.6   20480.0    11614.8   16384.0 15835.8 1792.0 1605.2      5    0.056   0      0.000    0.056
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT   
4608.0 1024.0  0.0   1008.0 32768.0  29610.6   20480.0    11614.8   16384.0 15835.8 1792.0 1605.2      5    0.056   0      0.000    0.056
4608.0 1024.0  0.0   1008.0 32768.0  29610.6   20480.0    11614.8   16384.0 15835.8 1792.0 1605.2      5    0.056   0      0.000    0.056
4608.0 1024.0  0.0   1008.0 32768.0  29610.6   20480.0    11614.8   16384.0 15835.8 1792.0 1605.2      5    0.056   0      0.000    0.056
4608.0 1024.0  0.0   1008.0 32768.0  29610.6   20480.0    11614.8   16384.0 15835.8 1792.0 1605.2      5    0.056   0      0.000    0.056
  • 显示字段说明
    PerfCounter key: jcmd 7654 PerfCounter.print |grep sun.gc.generation.0.space.1.capacity
    字段说明PerfCounter key
    S0C幸存区0(Survivor space 0)容量大小(kb) ,本例中为4608kbsun.gc.generation.0.space.1.capacity
    S1C幸存区1(Survivor space 1)容量大小(kb) ,本例中为1024kb,也就是两个幸存区大小不一定一样大sun.gc.generation.0.space.2.capacity
    S0U幸存区0已用空间(kb),本例中为0kbsun.gc.generation.0.space.1.used
    S1U幸存区1已用空间(kb),本例中为1008kbsun.gc.generation.0.space.2.used
    EC伊甸园(eden)容量大小(kb),本例中为32768kbsun.gc.generation.0.space.0.capacity
    EU伊甸园(eden)已用空间大小(kb),本例中为29610.6kbsun.gc.generation.0.space.0.used
    OC老年代(old)容量大小(kb),本例中为20480kbsun.gc.generation.1.space.0.capacity
    OU老年代(old)已用空间大小(kb),本例中为11614.8kbsun.gc.generation.1.space.0.used
    MC元空间(Metaspace)容量(Committed)大小(kb),本例中为16384kbsun.gc.metaspace.capacity
    MU元空间(Metaspace)已用空间大小(kb),本例中为15835.8kbsun.gc.metaspace.used
    CCSC压缩类空间(Compressed class space)容量(Committed)大小(kb),本例中为1792kbsun.gc.compressedclassspace.capacity
    CCSU压缩类空间已用空间大小(kb),本例中为1605.2 kbsun.gc.compressedclassspace.used
    YGC年轻代垃圾回收次数,本例中已执行了5次Young GCsun.gc.collector.0.invocations
    YGCT年轻代垃圾回收耗时(秒),本例中执行Young GC耗时0.056秒sun.gc.collector.0.time (纳秒)
    FGC整堆垃圾回收次数,本例中已执行了0次Full GCsun.gc.collector.1.invocations
    FGCT整堆垃圾回收耗时(秒),本例中执行Full GC耗时0秒sun.gc.collector.1.time (纳秒)
    GCT垃圾回收耗时(YGCT+FGCT),本例中为0.056秒可能是个计算量

垃圾收集-gcnew

此选项更关注年轻代垃圾回收,大部分信息被-gc选项覆盖。

# 以1秒/次速度显示1000次年轻代gc信息,每显示10次后重新显示标题
[root@localhost ~]# jstat -gcnew -h10 7654 1s 1000
 S0C    S1C    S0U    S1U   TT MTT  DSS      EC       EU     YGC     YGCT  
4608.0 5120.0 1248.0    0.0  5  15 5120.0  65024.0  14366.4      6    0.063
4608.0 5120.0 1248.0    0.0  5  15 5120.0  65024.0  14366.4      6    0.063
4608.0 5120.0 1248.0    0.0  5  15 5120.0  65024.0  14366.4      6    0.063
4608.0 5120.0 1248.0    0.0  5  15 5120.0  65024.0  14366.4      6    0.063
4608.0 5120.0 1248.0    0.0  5  15 5120.0  65024.0  14366.4      6    0.063
4608.0 5120.0 1248.0    0.0  5  15 5120.0  65024.0  14366.4      6    0.063
4608.0 5120.0 1248.0    0.0  5  15 5120.0  65024.0  14366.4      6    0.063
4608.0 5120.0 1248.0    0.0  5  15 5120.0  65024.0  14366.4      6    0.063
4608.0 5120.0 1248.0    0.0  5  15 5120.0  65024.0  14366.4      6    0.063
4608.0 5120.0 1248.0    0.0  5  15 5120.0  65024.0  14366.4      6    0.063
 S0C    S1C    S0U    S1U   TT MTT  DSS      EC       EU     YGC     YGCT  
4608.0 5120.0 1248.0    0.0  5  15 5120.0  65024.0  14366.4      6    0.063
4608.0 5120.0 1248.0    0.0  5  15 5120.0  65024.0  14366.4      6    0.063
4608.0 5120.0 1248.0    0.0  5  15 5120.0  65024.0  14366.4      6    0.063
4608.0 5120.0 1248.0    0.0  5  15 5120.0  65024.0  14366.4      6    0.063

从列信息中看,较-gc增加了TT、MTT、DSS三列,其余全部被-gc覆盖,索引只介绍新增的列,其余列可以参照-gc部分的描述

  • 显示字段说明
    PerfCounter key: jcmd 7654 PerfCounter.print |grep sun.gc.generation.0.space.1.capacity
    字段说明PerfCounter key
    TT年轻代对象晋升老年代阈值(动态计算),本地中为5sun.gc.policy.tenuringThreshold
    MTT年轻代对象晋升老年代最大阈(可通过-XX:MaxTenuringThreshold设置),本例中为15sun.gc.policy.maxTenuringThreshold
    DSSDesired survivor size 期望的幸存区大小(kb),本例为5120kbsun.gc.policy.desiredSurvivorSize

垃圾收集-gcold

此选项更关注老年代垃圾回收,全部信息都被-gc选项覆盖,不展开介绍。

# 以1秒/次速度显示1000次老年代gc信息,每显示10次后重新显示标题
[root@localhost ~]# jstat -gcold -h10 7654 1s 1000
   MC       MU      CCSC     CCSU       OC          OU       YGC    FGC    FGCT     GCT   
 16384.0  15954.0   1792.0   1605.7     20480.0     11614.8      6     0    0.000    0.063
 16384.0  15954.0   1792.0   1605.7     20480.0     11614.8      6     0    0.000    0.063
 16384.0  15954.0   1792.0   1605.7     20480.0     11614.8      6     0    0.000    0.063
 16384.0  15954.0   1792.0   1605.7     20480.0     11614.8      6     0    0.000    0.063
 16384.0  15954.0   1792.0   1605.7     20480.0     11614.8      6     0    0.000    0.063
 16384.0  15954.0   1792.0   1605.7     20480.0     11614.8      6     0    0.000    0.063
 16384.0  15954.0   1792.0   1605.7     20480.0     11614.8      6     0    0.000    0.063
 16384.0  15954.0   1792.0   1605.7     20480.0     11614.8      6     0    0.000    0.063
 16384.0  15954.0   1792.0   1605.7     20480.0     11614.8      6     0    0.000    0.063
 16384.0  15954.0   1792.0   1605.7     20480.0     11614.8      6     0    0.000    0.063
   MC       MU      CCSC     CCSU       OC          OU       YGC    FGC    FGCT     GCT   
 16384.0  15954.0   1792.0   1605.7     20480.0     11614.8      6     0    0.000    0.063
 16384.0  15954.0   1792.0   1605.7     20480.0     11614.8      6     0    0.000    0.063
 16384.0  15954.0   1792.0   1605.7     20480.0     11614.8      6     0    0.000    0.063

垃圾收集-gccapacity

# 显示各代容量信息
[root@localhost ~]# jstat -gccapacity 7654
 NGCMN    NGCMX     NGC     S0C   S1C       EC      OGCMN      OGCMX       OGC         OC       MCMN     MCMX      MC     CCSMN    CCSMX     CCSC    YGC    FGC 
 10240.0 155648.0  75776.0 4608.0 5120.0  65024.0    20480.0   311296.0    20480.0    20480.0      0.0 1064960.0  16384.0      0.0 1048576.0   1792.0      6     0
  • 显示字段说明
    PerfCounter key: jcmd 7654 PerfCounter.print |grep sun.gc.generation.0.minCapacity
    字段说明PerfCounter key
    NGCMN年轻代最小容量(kb) ,本例中为10240kbsun.gc.generation.0.minCapacity (字节)
    NGCMX年轻代最大容量(kb) ,本例中为155648kbsun.gc.generation.0.maxCapacity (字节)
    NGC当前年轻代容量(kb) ,本例中为75776kbsun.gc.generation.0.capacity (字节)
    S0C幸存区0容量(kb) ,本例中为4608kbsun.gc.generation.0.space.1.capacity (字节)
    S1C幸存区1容量(kb) ,本例中为5120kbsun.gc.generation.0.space.2.capacity (字节)
    EC伊甸园容量(kb) ,本例中为65024kbsun.gc.generation.0.space.0.capacity (字节)
    OGCMN老年代最小容量(kb) ,本例中为20480kbsun.gc.generation.1.minCapacity (字节)
    NGCMX老年代最大容量(kb) ,本例中为311296kbsun.gc.generation.1.maxCapacity (字节)
    OGC当前老年代容量,本例为20480kbsun.gc.generation.1.capacity (字节)
    OC当前老年区容量(老年代只有一个老年区),本例为20480kbsun.gc.generation.1.space.0.capacity
    MCMN元空间最小容量(kb) ,本例中为0kbsun.gc.metaspace.minCapacity (字节)
    MCMX元空间最大容量(kb) ,本例中为1064960kbsun.gc.metaspace.maxCapacity (字节)
    MC当前元空间容量,本例为16384kbsun.gc.metaspace.capacity (字节)
    CCSMNCompressed class space压缩类空间最小容量(kb) ,本例中为0kbsun.gc.compressedclassspace.minCapacity (字节)
    MCMX压缩类空间最大容量(kb) ,本例中为1048576kbsun.gc.compressedclassspace.maxCapacity (字节)
    CCSC当前压缩类空间容量,本例为1792kbsun.gc.compressedclassspace.capacity (字节)
    YGCYoung GC次数sun.gc.collector.0.invocations (次)
    FGCFull GC次数sun.gc.collector.1.invocations (次)

垃圾收集-gcnewcapacity

相比于-gccapacity,更关注与年轻代容量信息

# 查看年轻代容量信息
[root@localhost ~]# jstat -gcnewcapacity 7654
  NGCMN      NGCMX       NGC      S0CMX     S0C     S1CMX     S1C       ECMX        EC      YGC   FGC 
   10240.0   155648.0    75776.0  51712.0   4608.0  51712.0   5120.0   154624.0    65024.0     6     0

从列信息中看,较-gccapacity增加了S0CMX、S1CMX、ECMX三列,其余全部被-gccapacity覆盖,所以只介绍新增的列,其余列可以参照-gccapacity部分的描述

  • 显示字段说明
    PerfCounter key: jcmd 7654 PerfCounter.print |grep sun.gc.generation.0.minCapacity
    字段说明PerfCounter key
    S0CMX幸存区0最大容量(kb) ,本例中为51712kbsun.gc.generation.0.space.1.maxCapacity (字节)
    S1CMX幸存区1最大容量(kb) ,本例中为51712kbsun.gc.generation.0.space.2.maxCapacity (字节)
    ECMX伊甸园最大容量(kb) ,本例中为154624kbsun.gc.generation.0.space.0.maxCapacity (字节)

垃圾收集-gcoldcapacity

此选项更关注老年代垃圾回收,全部信息都被-gccapacity选项覆盖,不展开介绍。

# 显示老年代容量信息
[root@localhost ~]# jstat -gcoldcapacity 7654
   OGCMN       OGCMX        OGC         OC       YGC   FGC    FGCT     GCT   
    20480.0    311296.0     20480.0     20480.0     6     0    0.000    0.063

垃圾收集-gcmetacapacity

此选项更关注元空间垃圾回收,全部信息都被-gccapacity选项覆盖,不展开介绍。

# 显示元空间容量信息
[root@localhost ~]# jstat -gcmetacapacity 7654
   MCMN       MCMX        MC       CCSMN      CCSMX       CCSC     YGC   FGC    FGCT     GCT   
       0.0  1064960.0    16384.0        0.0  1048576.0     1792.0     6     0    0.000    0.063

垃圾收集-gcutil

以百分比的形式展示垃圾收集统计信息。

# 以1秒/次速率显示gc统计信息,每隔10行显示1次标题,直至手动结束(ctrl+c)或虚拟机终止
[root@localhost ~]# jstat -gcutil -t -h10 7654 1s
Timestamp         S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT   
        19053.4  27.08   0.00  83.40  56.71  97.38  89.60      6    0.063     0    0.000    0.063
        19054.4  27.08   0.00  83.40  56.71  97.38  89.60      6    0.063     0    0.000    0.063
        19055.4  27.08   0.00  83.40  56.71  97.38  89.60      6    0.063     0    0.000    0.063
        19056.4  27.08   0.00  83.40  56.71  97.38  89.60      6    0.063     0    0.000    0.063
        19057.4  27.08   0.00  83.40  56.71  97.38  89.60      6    0.063     0    0.000    0.063
        19058.4  27.08   0.00  83.40  56.71  97.38  89.60      6    0.063     0    0.000    0.063
        19059.4  27.08   0.00  83.40  56.71  97.38  89.60      6    0.063     0    0.000    0.063
        19060.4  27.08   0.00  83.40  56.71  97.38  89.60      6    0.063     0    0.000    0.063
        19061.4  27.08   0.00  83.40  56.71  97.38  89.60      6    0.063     0    0.000    0.063
        19062.5  27.08   0.00  83.40  56.71  97.38  89.60      6    0.063     0    0.000    0.063
Timestamp         S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT   
        19063.4  27.08   0.00  83.40  56.71  97.38  89.60      6    0.063     0    0.000    0.063
        19064.4  27.08   0.00  83.40  56.71  97.38  89.60      6    0.063     0    0.000    0.063
        19065.4  27.08   0.00  83.40  56.71  97.38  89.60      6    0.063     0    0.000    0.063
		.....

显示字段解释:
S0: 幸存区0(Survivor space 0)使用百分比,本例为27.8%.
S1: 幸存区1(Survivor space 1)使用百分比,本例为0%.
E: 伊甸园(Eden space)使用百分比,本例为83.4%.
O: 老年区(Old space)使用百分比,本例为56.71%.
M: 元空间(Metaspace)使用百分比,本例为97.38%.
CCS: 压缩类空间(Compressed class space)使用百分比,本例为89.6%.
YGC: 年轻代发生垃圾回收次数,本例中发生6次年轻代垃圾回收.
YGCT: 年轻代垃圾回收耗时(s),本例中YGC耗时0.063秒.
FGC: Full GC次数,本例发生0次Full GC.
FGCT: Full GC耗时(s),本例FGC耗时0秒.
GCT: GCT=YGCT+FGCT,即所有垃圾回收耗时,本例所有垃圾回收耗时0.063秒

垃圾收集-gccause

显示的GC统计信息与-gcutil一致,额外增加上一次GC发生原因(LGCC)和当前GC发生原因(GCC)。

# 查看gc引发原因,每两秒查看异常,查看5次
[root@localhost ~]# jstat -gccause 7654 2s 5
  S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT    LGCC                 GCC                 
 27.08   0.00  98.99  56.71  97.38  89.60      6    0.063     0    0.000    0.063 Allocation Failure   No GC               
 27.08   0.00  98.99  56.71  97.38  89.60      6    0.063     0    0.000    0.063 Allocation Failure   No GC               
 27.08   0.00  98.99  56.71  97.38  89.60      6    0.063     0    0.000    0.063 Allocation Failure   No GC               
 27.08   0.00  98.99  56.71  97.38  89.60      6    0.063     0    0.000    0.063 Allocation Failure   No GC               
 27.08   0.00  98.99  56.71  97.38  89.60      6    0.063     0    0.000    0.063 Allocation Failure   No GC

本例中上次GC原因为分配对象内存失败(Allocation Failure);监控期间无GC发生,因此GCC为No GC。

参考链接

JDK13-index:https://docs.oracle.com/en/java/javase/13/docs/specs/man/index.html
JDK13-jstat:https://docs.oracle.com/en/java/javase/13/docs/specs/man/jstat.html
JDK8-index:https://docs.oracle.com/javase/8/docs/technotes/tools/unix/
JDK8-jstat:https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jstat.html#BEHHGFAE

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值