美文网首页
JVM调优常用指令之jstat

JVM调优常用指令之jstat

作者: 有梦想的虫子_2018 | 来源:发表于2020-09-16 16:00 被阅读0次

官方文档地址:jstat https://docs.oracle.com/javase/9/tools/jstat.htm#JSWOR734
参考博客: 【JVM】jstat命令详解---JVM的统计监测工具

一、jstat介绍

The jstat command displays performance statistics for an instrumented Java HotSpot VM. 
The target JVM is identified by its virtual machine identifier, or vmid option.
You use the jstat command to monitor JVM statistics. 

可以理解为:查看虚拟机性能统计信息

[root@VM_0_12_centos /]# jstat -help
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.

语法:

jstat generalOptions
jstat -outputOptions [ -t] [-hlines] vmid [interval [count] ]

二、generalOptions 通用选项

jstat -help|-options

[root@VM_0_12_centos /]# jstat -options
-class         
-compiler  
-gc      
-gccapacity 
-gccause
-gcmetacapacity
-gcnew
-gcnewcapacity
-gcold
-gcoldcapacity
-gcutil
-printcompilation

三、outputOptions 需要统计的选项

1、jstat -class PID

Class loader statistics.类加载信息

[root@VM_0_12_centos /]# jstat -class 30157
Loaded  Bytes  Unloaded  Bytes     Time   
  4005  8105.4        0     0.0       3.06
Loaded: Number of classes loaded.    加载class的数量
Bytes: Number of KB loaded.              所占用空间单位KB
Unloaded: Number of classes unloaded.  卸载的class的数量
Bytes: Number of KB loaded.               所占用空间单位KB
Time: Time spent performing class loading and unloading operations. 装载、卸载class的时间

2、 jstat -compiler PID

Java HotSpot VM Just-in-Time compiler statistics.实时编译统计

[root@VM_0_12_centos /]# jstat -compiler 30157
Compiled Failed Invalid   Time   FailedType FailedMethod
    4337      0       0     7.16          0  
Compiled: Number of compilation tasks performed.    编译完成的数量
Failed: Number of compilations tasks failed.                编译失败的数量       
Invalid: Number of compilation tasks that were invalidated.  无效编译的数量
Time: Time spent performing compilation tasks.    执行编译所花费的时间
FailedType: Compile type of the last failed compilation. 编译失败的类型
FailedMethod: Class name and method of the last failed compilation. 编译失败的方法

3、jstat -gc PID

Garbage collected heap statistics.垃圾收集器堆统计信息

[root@VM_0_12_centos /]# jstat -gc 30157
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT   
2176.0 2176.0  0.0   1925.7 17600.0  17416.6   43712.0    26014.5   27776.0 27017.7 2944.0 2800.6     23    0.158   1      0.027    0.184
S0C: Current survivor space 0 capacity (KB).   S0区容量
S1C: Current survivor space 1 capacity (KB).   S1区容量
S0U: Survivor space 0 utilization (KB).        S0使用大小
S1U: Survivor space 1 utilization (KB).        S1使用大小
EC: Current eden space capacity (KB).         eden容量
EU: Eden space utilization (KB).              eden使用大小
OC: Current old space capacity (KB).        老年代容量
OU: Old space utilization (KB).             老年代使用大小
MC: Metaspace capacity (KB).            元空间大小
MU: Metaspace utilization (KB).         元空间使用大小
CCSC: Compressed class space capacity (KB).  压缩类空间大小
CCSU: Compressed class space used (KB).   压缩类空间使用大小
YGC: Number of young generation garbage collection (GC) events.  年轻代垃圾回收次数
YGCT: Young generation garbage collection time.      年轻代垃圾回收消耗时间
FGC: Number of full GC events.        full GC垃圾回收次数
FGCT: Full garbage collection time.     full GC垃圾回收消耗时间
GCT: Total garbage collection time.     垃圾收集总时间

4、jstat -gccapacity PID

Memory pool generation and space capacities. 堆容量大小

[root@VM_0_12_centos /]# jstat -gccapacity 30157
 NGCMN    NGCMX     NGC     S0C   S1C       EC      OGCMN      OGCMX       OGC         OC       MCMN     MCMX      MC     CCSMN    CCSMX     CCSC    YGC    FGC 
 21824.0  87360.0  21952.0 2176.0 2176.0  17600.0    43712.0   174784.0    43712.0    43712.0      0.0 1075200.0  27776.0      0.0 1048576.0   2944.0     24     1
NGCMN: Minimum new generation capacity (KB).    新生代最小容量
NGCMX: Maximum new generation capacity (KB).    新生代最大容量
NGC: Current new generation capacity (KB).      当前新生代容量
S0C: Current survivor space 0 capacity (KB).    当前S0容量
S1C: Current survivor space 1 capacity (KB).    当前S1容量
EC: Current eden space capacity (KB).           当前eden容量
OGCMN: Minimum old generation capacity (KB).  老年代最小容量
OGCMX: Maximum old generation capacity (KB). 老年代最大容量
OGC: Current old generation capacity (KB).   当前老年代容量
OC: Current old space capacity (KB).  当前老年代容量
MCMN: Minimum metaspace capacity (KB). 元空间最小容量
MCMX: Maximum metaspace capacity (KB). 元空间最大容量
MC: Metaspace capacity (KB). 元空间容量
CCSMN: Compressed class space minimum capacity (KB). 压缩类空间最小容量
CCSMX: Compressed class space maximum capacity (KB).压缩类空间最大容量
CCSC: Compressed class space capacity (KB).压缩类空间容量
YGC: Number of young generation GC events. 年轻代垃圾回收次数
FGC: Number of full GC events. full GC垃圾回收次数

5、jstat -gccause PID

[root@VM_0_12_centos /]# jstat -gccause 30157
  S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT    LGCC                 GCC                 
  0.00 100.00  10.80  70.08  97.33  95.61     33    0.224     1    0.027    0.250 Allocation Failure   No GC
LGCC: Cause of last garbage collection  上次垃圾收集的原因
GCC: Cause of current garbage collection 当前垃圾收集的原因

6、jstat -gcnew PID

[root@VM_0_12_centos /]# jstat -gcnew 30157

**New generation statistics. 新生代统计**
 S0C    S1C    S0U    S1U   TT MTT  DSS      EC       EU     YGC     YGCT  
2176.0 2176.0    0.0 1994.2  1  15 1088.0  17600.0  15414.1     31    0.210
S0C: Current survivor space 0 capacity (KB).
S1C: Current survivor space 1 capacity (KB).
S0U: Survivor space 0 utilization (KB).
S1U: Survivor space 1 utilization (KB).
TT: Tenuring threshold.    对象在新生代存活的次数
MTT: Maximum tenuring threshold. 对象在新生代存活的最大次数
DSS: Desired survivor size (KB). 期望的幸存区大小
EC: Current eden space capacity (KB).
EU: Eden space utilization (KB).
YGC: Number of young generation GC events.
YGCT: Young generation garbage collection time.

7、jstat -gcnewcapacity PID

New generation space size statistics. 新生代空间大小统计

[root@VM_0_12_centos /]# jstat -gcnewcapacity 30157
  NGCMN      NGCMX       NGC      S0CMX     S0C     S1CMX     S1C       ECMX        EC      YGC   FGC 
   21824.0    87360.0    21952.0   8704.0   2176.0   8704.0   2176.0    69952.0    17600.0    32     1
NGCMN: Minimum new generation capacity (KB).
NGCMX: Maximum new generation capacity (KB).
NGC: Current new generation capacity (KB).
S0CMX: Maximum survivor space 0 capacity (KB).
S0C: Current survivor space 0 capacity (KB).
S1CMX: Maximum survivor space 1 capacity (KB).
S1C: Current survivor space 1 capacity (KB).
ECMX: Maximum eden space capacity (KB).
EC: Current eden space capacity (KB).
YGC: Number of young generation GC events.
FGC: Number of full GC events.

8、other option

gcold: Displays statistics about the behavior of the old generation and metaspace statistics.

gcoldcapacity: Displays statistics about the sizes of the old generation.

gcmetacapacity: Displays statistics about the sizes of the metaspace.

gcutil: Displays a summary about garbage collection statistics.

printcompilation: Displays Java HotSpot VM compilation method statistics.

-JjavaOption
Passes javaOption to the Java application launcher. For example, -J-Xms48m sets the startup memory to 48 MB. For a complete list of options, see java.

面对每一道题目,要学会把自己的思维发散出去。每一篇文章只当自己对知识的总结!

相关文章

网友评论

      本文标题:JVM调优常用指令之jstat

      本文链接:https://www.haomeiwen.com/subject/wxncyktx.html