jstat
Introduction
The jstat is a JVM statistics monitoring tool provided by the JDK. It uses the built-in instructions of the JVM to monitor the resources and performance of Java applications in real time, including the heap size and GC status of applications.
Installation Method
After the JDK is installed, the jstat tool is delivered with the JDK and you do not need to install it. The jstat tool is generally stored in the bin directory of Java.
How to Use
jstat is a powerful command with many options. You can view the usage of each part in the heap and the number of loaded classes. When using this command, you need to add the PID of the process to be viewed and the selected parameters.
Command format: jstat [Parameter] <pid>
The main functions of level-1 parameters are as follows:
Parameter |
Description |
|---|---|
jstat -class <pid> |
Displays the number of loaded classes and the space occupied by the classes. |
jstat -compiler <pid> |
Displays information such as the number of VMs that are compiled in real time. |
jstat -gc <pid> |
Displays GC information, including the number of GC times and GC time. |
jstat -gccapacity <pid> |
Displays the usage and space of the third-generation objects in the VM memory. |
jstat -gcutil <pid> |
Displays the GC statistics. |
jstat -gcnew <pid> |
Displays information about young-generation objects. |
jstat -gcnewcapacity <pid> |
Displays information about young-generation objects and their memory usage. |
jstat -gcold <pid> |
Displays information about old-generation objects. |
jstat -gcpermcapacity <pid> |
Displays information about the permanent-generation objects and their usage. |
jstat -printcompilation <pid> |
Displays the execution information about the current VM. |
During GC optimization, the jstat -gc <pid> command is frequently used. The output parameters and their meanings are as follows:
Parameter |
Description |
|---|---|
S0C |
Capacity of the first survivor in the young generation (in bytes) |
S1C |
Capacity of the second survivor in the young generation (in bytes) |
S0U |
Used space of the first survivor in the young generation (in bytes) |
S1U |
Used space of the second survivor in the young generation (in bytes) |
EC |
Capacity of Eden in the young generation (in bytes) |
EU |
Used space of Eden in the young generation (in bytes) |
OC |
Capacity of the old generation (in byte) |
OU |
Used space of the old generation (in bytes) |
PC |
Capacity of the permanent generation (in bytes) |
PU |
Used space of the permanent generation (in bytes) |
YGC |
Number of GC operations in the young generation from the application startup to sampling |
YGCT |
GC duration in the young generation from the application startup to sampling (in seconds) |
FGC |
Number of full GC operations in the young generation from the application startup to sampling |
FGCT |
Full GC duration in the old generation from the application startup to sampling (in seconds) |
GCT |
Total GC duration from the application startup to sampling (in seconds) |
Output format:
1 | # jstat -gc 2342
|
1 2 3 | sh-4.4# jstat -gc 159 1000 S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT 6144.0 13824.0 6128.8 0.0 702464.0 590176.1 497664.0 468611.6 139032.0 131745.2 15664.0 14404.5 151478 1673.004 1057 343.310 2016.314 6144.0 13824.0 6128.8 0.0 702464.0 590237.9 497664.0 468611.6 139032.0 131745.2 15664.0 14404.5 151478 1673.004 1057 343.310 2016.314 6144.0 13824.0 6128.8 0.0 702464.0 592583.5 497664.0 468611.6 139032.0 131745.2 15664.0 14404.5 151478 1673.004 1057 343.310 2016.314 6144.0 13824.0 6128.8 0.0 702464.0 592715.7 497664.0 468611.6 139032.0 131745.2 15664.0 14404.5 151478 1673.004 1057 343.310 2016.314 6144.0 13824.0 6128.8 0.0 702464.0 592715.7 497664.0 468611.6 139032.0 131745.2 15664.0 14404.5 151478 1673.004 1057 343.310 2016.314 6144.0 13824.0 6128.8 0.0 702464.0 592715.7 497664.0 468611.6 139032.0 131745.2 15664.0 14404.5 151478 1673.004 1057 343.310 2016.314 |