The jstat utility is a statistics
monitoring tool. It attaches to a Java VM and collects and logs performance
statistics as specified by the command-line options. The target Java
VM is identified by its virtual machine identifier.
The jstat utility does not
require the Java VM to be started with any special options. This utility
is included in the JDK download.
The following table lists the jstat command options:
Table 1-13 Options to the jstat Command
| -class | Prints statistics
on the behavior of the class loader |
| -compiler | Prints statistics
on the behavior of the Java compiler |
| -gc | Prints statistics on
the behavior of the garbage collected heap |
| -gccapacity | Prints statistics
of the capacities of the generations and their corresponding spaces |
| -gccause | Prints the summary
of garbage collection statistics with the cause of the last and current
(if applicable) garbage collection events |
| -gcnew | Prints statistics
of the behavior of the new generation |
| -gcnewcapacity | Prints statistics
of the sizes of the new generations and their corresponding spaces |
| -gcold | Prints statistics
of the behavior of the old and permanent generations |
| -gcoldcapacity | Prints statistics
of the sizes of the old generation |
| -gcpermcapacity | Prints
statistics of the sizes of the permanent generation |
| -gcutil | Prints a summary
of garbage collection statistics |
| -printcompilation | Prints
Java compilation method statistics |
A complete description of the jstat tool, including examples, can be found at:
http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jstat.html
The following example of the jstat command attaches to pid 27395 and takes five samples at 250 millisecond
intervals. The -gcnew option specifies that statistics
of the behavior of the new generation is output.
$ jstat -gcnew 27395 250 5
S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT
64.0 64.0 0.0 31.7 31 31 32.0 512.0 178.6 249 0.203
64.0 64.0 0.0 31.7 31 31 32.0 512.0 355.5 249 0.203
64.0 64.0 35.4 0.0 2 31 32.0 512.0 21.9 250 0.204
64.0 64.0 35.4 0.0 2 31 32.0 512.0 245.9 250 0.204
64.0 64.0 35.4 0.0 2 31 32.0 512.0 421.1 250 0.204 |
The following table lists the descriptions of
the column headings in the example:
Table 1-14 jstat — New Generation Statistics
| Column | Description |
|---|
| 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 |