jstat tool
About 1001 wordsAbout 3 minDecember 3, 2024
Displaying GC Statistics
Use the -gc
option to display garbage collection-related statistics:
jstat -gc <PID>
Sample output:
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
1024.0 1024.0 0.0 512.0 8192.0 4096.0 20480.0 10240.0 3200.0 1600.0 512.0 256.0 5 0.100 2 0.200 0.300
Field explanations:
- S0C / S1C: Capacity of Survivor 0 and Survivor 1 spaces in the young generation Eden space (KB).
- S0U / S1U: Used space in Survivor 0 and Survivor 1 spaces in the young generation Eden space (KB).
- EC: Capacity of the Eden space in the young generation (KB).
- EU: Used space in the Eden space in the young generation (KB).
- OC: Capacity of the old generation (KB).
- OU: Used space in the old generation (KB).
- MC: Capacity of the Metaspace (KB).
- MU: Used space in the Metaspace (KB).
- CCSC: Capacity of the compressed class space (KB).
- CCSU: Used space in the compressed class space (KB).
- YGC: Number of young generation GCs.
- YGCT: Time spent on young generation GCs (seconds).
- FGC: Number of old generation GCs.
- FGCT: Time spent on old generation GCs (seconds).
- GCT: Total time spent on GCs (seconds).
Displaying Class Loading Statistics
Use the -class
option to display class loading-related statistics:
jstat -class <PID>
Sample output:
Loaded Bytes Unloaded Bytes Time
1024 512000 100 50000 0.50
Field explanations:
- Loaded: Number of classes loaded.
- Bytes: Bytes occupied by loaded classes.
- Unloaded: Number of classes unloaded.
- Bytes: Bytes freed by unloaded classes.
- Time: Total time spent on class loading and unloading (seconds).
Displaying Compiler Statistics
Use the -compiler
option to display JIT compiler-related statistics:
jstat -compiler <PID>
Sample output:
Compiled Failed Invalid Time FailedType FailedMethod
2048 2 0 15.00 1 MyClass::myMethod
Field explanations:
- Compiled: Number of methods compiled.
- Failed: Number of methods that failed to compile.
- Invalid: Number of invalid compilations.
- Time: Total time spent on compilation (seconds).
- FailedType: Type of the last compilation failure.
- FailedMethod: Name of the method that failed last to compile.
Displaying GC Utilization Statistics
Use the -gcutil
option to display garbage collection-related memory utilization:
jstat -gcutil <PID>
Sample output:
S0 S1 E O M CCS YGC YGCT FGC FGCT GCT
0.0 50.0 25.0 50.0 50.0 50.0 5 0.100 2 0.200 0.300
Field explanations:
- S0 / S1: Memory utilization of Survivor 0 and Survivor 1 spaces in the young generation Eden space (%).
- E: Memory utilization of the Eden space in the young generation (%).
- O: Memory utilization of the old generation (%).
- M: Memory utilization of the Metaspace (%).
- CCS: Memory utilization of the compressed class space (%).
- YGC: Number of young generation GCs.
- YGCT: Time spent on young generation GCs (seconds).
- FGC: Number of old generation GCs.
- FGCT: Time spent on old generation GCs (seconds).
- GCT: Total time spent on GCs (seconds).
Displaying Memory Area Capacity and Usage
Use the -gccapacity
option to display the capacity and usage of memory areas (such as young generation, old generation, and permanent generation):
jstat -gccapacity <PID>
Sample output:
NGCMN NGCMX NGC S0C S1C EC OGCMN OGCMX OGC OC CCNM CCNX CCMX CCSMN CCSMX CCSC CCSU
2048.0 8192.0 4096.0 512.0 512.0 3072.0 10240.0 20480.0 15360.0 10240.0 1024.0 2048.0 3072.0 1024.0 2048.0 1536.0 1024.0
Field explanations:
- NGCMN: Minimum capacity of the young generation (KB).
- NGCMX: Maximum capacity of the young generation (KB).
- NGC: Current capacity of the young generation (KB).
- S0C / S1C: Capacity of Survivor 0 and Survivor 1 spaces in the young generation Eden space (KB).
- EC: Capacity of the Eden space in the young generation (KB).
- OGCMN: Minimum capacity of the old generation (KB).
- OGCMX: Maximum capacity of the old generation (KB).
- OGC: Current capacity of the old generation (KB).
- OC: Capacity of the old generation (KB).
- CCNM / CCNX: Minimum and maximum capacities of the compressed class space (KB).
- CCMX: Current capacity of the compressed class space (KB).
- CCSMN / CCSMX: Minimum and maximum capacities of the compressed class space (KB).
- CCSC: Capacity of the compressed class space (KB).
- CCSU: Used space in the compressed class space (KB).
Displaying Metaspace Capacity and Usage
Use the -gcmetacapacity
option to display the capacity and usage of the JVM metadata area (Metaspace):
jstat -gcmetacapacity <PID>
Sample output:
MC MU CCSC CCSU
3200.0 1600.0 512.0 256.0
Field explanations:
- MC: Capacity of the Metaspace (KB).
- MU: Used space in the Metaspace (KB).
- CCSC: Capacity of the compressed class space (KB).
- CCSU: Used space in the compressed class space (KB).