Detailed explanation of the use of jstat command in Java

Introduction to the jstat command

jstat (Java Virtual Machine Statistics Monitoring Tool) is a command-line tool provided by the JDK that can monitor various running status information of the Java virtual machine. It can display information about the running status of class loading, memory, garbage collection, just-in-time compilation, etc. in the Java virtual machine.

jstat command parameters

Command syntax:

jstat generalOptions
jstat outputOptions [-t] [-h<lines>] <vmid> [<interval> [<count>]]

Command parameter description:

  • generalOptions: Generic options, if you specify a generic option, you cannot specify any other options or parameters. It includes the following two options:
    • -help: Displays help information.
    • -options: Displays outputOptionsa list of parameters.
  • outputOptions: Output options, specify to display a certain kind of Java virtual machine information.
  • -t: Display the timestamp column as the first column of the output. This timestamp is the number of seconds since the start of the Java virtual machine.
  • -h n: Display the header every n lines, where n is a positive integer. The default value is 0, that is, the header is only displayed once in the first row of data.
  • vmid: The unique ID of the virtual machine (LVMID, Local Virtual Machine Identifier), if you view the local machine, it is the process ID of the Java process.
  • interval: The time interval for displaying information, in milliseconds by default. You can also specify seconds as the unit, for example: 1s. If this parameter is specified, the jstat command will display statistics every time period.
  • count: The number of times to display data, the default value is infinity, which will cause the jstat command to display statistics until the target JVM terminates or the jstat command terminates.

output options

If you do not specify general options (generalOptions), you can specify output options (outputOptions). The output options determine the content and format displayed by the jstat command, as follows:

  • -class: Displays statistics about the number of classes loaded, unloaded, total space, and loading time.
  • -compiler: Displays information such as the method and time consuming of real-time compilation.
  • -gc: Displays statistics on memory usage and garbage collection for each area of ​​the heap.
  • -gccapacity: Displays the capacity of each area of ​​the heap and the statistics of the corresponding space.
  • -gcutil: Displays a summary of garbage collection statistics.
  • -gccause: Displays a summary of statistics about garbage collections (same as -gcutil), and the reasons for recent and current garbage collections.
  • -gcnew: Displays garbage collection statistics for the young generation.
  • -gcnewcapacity: Displays the size of the new generation and the statistics of its corresponding space.
  • -gcold: Displays garbage collection statistics for the old generation and metaspace.
  • -gcoldcapacity: Displays the size statistics of the old generation.
  • -gcmetacapacity: Displays statistics about the size of the metaspace.
  • -printcompilation: Displays statistics for just-in-time compiled methods.

The display output of the jstat command is formatted as a table with columns separated by spaces. Next, I'll take a look at the column names for each output option.

-class option

  1. Loaded: The number of loaded classes.
  2. Bytes: The number of bytes occupied by the loaded class.
  3. Unloaded: The number of unloaded classes.
  4. Bytes: The number of bytes occupied by unloaded classes.
  5. Time: Time spent performing class loading and unloading operations.

for example:

Manneko Gakusha.png

-compiler option

  1. Compiled: The number of compiled tasks executed.
  2. Failed: The number of failed compilation tasks.
  3. Invalid: The number of failed compilation tasks.
  4. Time: The time spent executing the compilation task.
  5. FailedType: The compilation type that failed the last compilation.
  6. FailedMethod: The class name and method for which the last compilation failed.

for example:

Manneko Gakusha.png

-gc option

  1. SOC: The capacity of the first Survivor area in the young generation, in KB.
  2. S1C: The capacity of the second Survivor area in the young generation, in KB.
  3. S0U: The used size of the first Survivor area in the young generation, in KB.
  4. S1U: The used size of the second Survivor area in the young generation, in KB.
  5. EC: The capacity of the Eden area in the young generation, in KB.
  6. EU: The used size of the Eden area in the young generation, in KB.
  7. OC: The capacity of the old age, in KB.
  8. OU: The used size of the old generation, in KB.
  9. MC: The capacity of the meta space, in KB.
  10. MU: The used size of the meta space, in KB.
  11. CCSC: The capacity of the compressed class, in KB.
  12. CCSU: Compression class used size, in KB.
  13. YGC: The number of Young GCs.
  14. YGCT: Time spent by Young GC.
  15. FGC: The number of Full GCs.
  16. FGCT: The time spent in Full GC.
  17. GCT: The total time spent by the GC.

for example:

Manneko Gakusha.png

-gccapacity option

  1. NGCMN: The smallest capacity of the young generation, in KB.
  2. NGCMX: The maximum capacity of the young generation, in KB.
  3. NGC: The capacity of the current young generation, in KB.
  4. SOC: The capacity of the first Survivor area in the young generation, in KB.
  5. S1C: The capacity of the second Survivor area in the young generation, in KB.
  6. EC: The capacity of the Eden area in the young generation, in KB.
  7. OGCMN: The smallest size of the old generation, in KB.
  8. OGCMX: The maximum capacity of the old generation, in KB.
  9. OGC: The capacity of the current old generation, in KB.
  10. OC: The capacity of the current old age, in KB.
  11. MCMN: The minimum capacity of the meta space, in KB.
  12. MCMX: The maximum capacity of the meta space, in KB.
  13. MC: The capacity of the current meta space, in KB.
  14. CCSMN: The minimum size of the compression class, in KB.
  15. CCSMX: The maximum capacity of the compression class, in KB.
  16. CCSC: The capacity of the current compression class, in KB.
  17. YGC: The number of Young GCs.
  18. FGC: The number of Full GCs.

for example:

Manneko Gakusha.png

-gcutil option

  1. S0: The percentage of the used size of the first Survivor area in the young generation to the current capacity.
  2. S1: The percentage of the used size of the second Survivor area in the young generation to the current capacity.
  3. E: The percentage of the used size of the Eden area to the current capacity.
  4. O: The percentage of the old generation usage size to the current capacity.
  5. M: Metaspace usage size as a percentage of current capacity.
  6. CCS: Compression class usage size as a percentage of current capacity.
  7. YGC: The number of Young GCs.
  8. YGCT: Time spent by Young GC.
  9. FGC: The number of Full GCs.
  10. FGCT: The time spent in Full GC.
  11. GCT: The total time spent by the GC.

for example:

Manneko Gakusha.png

-gccause option

  1. S0: The percentage of the used size of the first Survivor area in the young generation to the current capacity.
  2. S1: The percentage of the used size of the second Survivor area in the young generation to the current capacity.
  3. E: The percentage of the used size of the Eden area to the current capacity.
  4. O: The percentage of the old generation usage size to the current capacity.
  5. M: Metaspace usage size as a percentage of current capacity.
  6. CCS: Compression class usage size as a percentage of current capacity.
  7. YGC: The number of Young GCs.
  8. YGCT: Time spent by Young GC.
  9. FGC: The number of Full GCs.
  10. FGCT: The time spent in Full GC.
  11. GCT: The total time spent by the GC.
  12. LGCC: The reason for the last garbage collection.
  13. GCC: The reason for the current garbage collection.

for example:

Manneko Gakusha.png

-gcnew option

  1. SOC: The capacity of the first Survivor area in the young generation, in KB.
  2. S1C: The capacity of the second Survivor area in the young generation, in KB.
  3. S0U: The used size of the first Survivor area in the young generation, in KB.
  4. S1U: The used size of the second Survivor area in the young generation, in KB.
  5. TT: The number of times the object has survived in the young generation.
  6. MTT: The maximum number of times an object survives in the young generation
  7. DSS: The expected Survivor area size, in KB.
  8. EC: The capacity of the Eden area in the young generation, in KB.
  9. EU: The used size of the Eden area in the young generation, in KB.
  10. YGC: The number of Young GCs.
  11. YGCT: Time spent by Young GC.

for example:

Manneko Gakusha.png

-gcnewcapacity option

  1. NGCMN: The smallest capacity of the young generation, in KB.
  2. NGCMX: The maximum capacity of the young generation, in KB.
  3. NGC: The capacity of the current young generation, in KB.
  4. S0CMX: The maximum capacity of the first Survivor area in the young generation, in KB.
  5. SOC: The capacity of the first Survivor area in the young generation, in KB.
  6. S1CMX: The maximum capacity of the second Survivor area in the young generation, in KB.
  7. S1C: The capacity of the second Survivor area in the young generation, in KB.
  8. ECMX: The maximum capacity of the Eden area in the young generation, in KB.
  9. EC: The capacity of the Eden area in the young generation, in KB.
  10. YGC: The number of Young GCs.
  11. FGC: The number of Full GCs.

for example:

Manneko Gakusha.png

-gcold option

  1. MC: The capacity of the meta space, in KB.
  2. MU: The used size of the meta space, in KB.
  3. CCSC: The capacity of the compressed class, in KB.
  4. CCSU: Compression class used size, in KB.
  5. OC: The capacity of the old age, in KB.
  6. OU: The used size of the old generation, in KB.
  7. YGC: The number of Young GCs.
  8. FGC: The number of Full GCs.
  9. FGCT: The time spent in Full GC.
  10. GCT: The total time spent by the GC.

for example:

Manneko Gakusha.png

-gcoldcapacity option

  1. OGCMN: The smallest size of the old generation, in KB.
  2. OGCMX: The maximum capacity of the old generation, in KB.
  3. OGC: The capacity of the current old generation, in KB.
  4. OC: The capacity of the current old age, in KB.
  5. YGC: The number of Young GCs.
  6. FGC: The number of Full GCs.
  7. FGCT: The time spent in Full GC.
  8. GCT: The total time spent by the GC.

for example:

Manneko Gakusha.png

-gcmetacapacity option

  1. MCMN: The minimum capacity of the meta space, in KB.
  2. MCMX: The maximum capacity of the meta space, in KB.
  3. MC: The capacity of the current meta space, in KB.
  4. CCSMN: The minimum size of the compression class, in KB.
  5. CCSMX: The maximum capacity of the compression class, in KB.
  6. YGC: The number of Young GCs.
  7. FGC: The number of Full GCs.
  8. FGCT: The time spent in Full GC.
  9. GCT: The total time spent by the GC.

for example:

Manneko Gakusha.png

-printcompilation option

Compiled: The number of compilation tasks performed by the most recent compile method. Size: The number of bytes of bytecode of the most recently compiled method. Type: The compilation type of the most recently compiled method. Method: The class name and method name of the most recently compiled method.

for example:

Manneko Gakusha.png

Finally, thank you for being so handsome, and for giving me likes and attention .

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324108831&siteId=291194637