jstat(1)
okay so you found jstat(1), from the Monitoring Tools part of the manual, and she is lowkey iconic: Java Virtual Machine (JVM) stats with main character energy π
β¨ Grab a snack, bestie.
πΈ NAME πΈ
jstat β Monitors Java Virtual Machine (JVM) statistics. This command is experimental and unsupported. π«Ά
β¨ SYNOPSIS β¨
jstat [ generalOption | outputOptions vmid [ interval[s|ms] [ count ] ]
generalOptionβ A single general command-line option-helpor-options. See General Options.outputOptionsβ One or more output options that consist of a singlestatOption, plus any of the-t,-h, and-Joptions. See Output Options.vmidβ Virtual machine identifier, which is a string that indicates the target JVM. The general syntax is the following:
[protocol:][//]lvmid[@hostname[:port]/servername]
The syntax of the vmid string corresponds to the syntax of a URI. The vmid string can vary from a simple integer that represents a local JVM to a more complex construction that specifies a communications protocol, port number, and other implementation-specific values. See Virtual Machine Identifier.
interval [s|ms]β Sampling interval in the specified units, seconds (s) or milliseconds (ms). Default units are milliseconds. Must be a positive integer. When specified, thejstatcommand produces its output at each interval.countβ Number of samples to display. The default value isinfinity, which causes thejstatcommand to display statistics until the target JVM terminates or thejstatcommand is terminated. This value must be a positive integer.
π¦ DESCRIPTION π¦
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. π
π VIRTUAL MACHINE IDENTIFIER π
The syntax of the vmid string corresponds to the syntax of a URI:
[protocol:][//]lvmid[@hostname[:port]/servername]
protocolβ The communications protocol. If theprotocolvalue is omitted and a host name is not specified, then the default protocol is a platform-specific optimized local protocol. If theprotocolvalue is omitted and a host name is specified, then the default protocol isrmi.lvmidβ The local virtual machine identifier for the target JVM. Thelvmidis a platform-specific value that uniquely identifies a JVM on a system. Thelvmidis the only required component of a virtual machine identifier. Thelvmidis typically, but not necessarily, the operating system's process identifier for the target JVM process. You can use thejpscommand to determine thelvmid. Also, you can determine thelvmidon Solaris, Linux, and OS X platforms with thepscommand, and on Windows with the Windows Task Manager.hostnameβ A hostname or IP address that indicates the target host. If thehostnamevalue is omitted, then the target host is the local host.portβ The default port for communicating with the remote server. If thehostnamevalue is omitted or theprotocolvalue specifies an optimized, local protocol, then theportvalue is ignored. Otherwise, treatment of theportparameter is implementation-specific. For the defaultrmiprotocol, theportvalue indicates the port number for thermiregistryon the remote host. If theportvalue is omitted and theprotocolvalue indicatesrmi, then the defaultrmiregistryport (1099) is used.servernameβ The treatment of theservernameparameter depends on implementation. For the optimized local protocol, this field is ignored. For thermiprotocol, it represents the name of the RMI remote object on the remote host.
π OPTIONS π
The jstat command supports two types of options, general options and output options. General options cause the jstat command to display simple usage and version information. Output options determine the content and format of the statistical output.
π¨ All options and their functionality are subject to change or removal in future releases.
π General Options
If you specify one of the general options, then you cannot specify any other option or parameter. No mixing, bestie.
-helpβ Displays a help message.-optionsβ Displays a list of static options. See Output Options.
π Output Options
If you do not specify a general option, then you can specify output options. Output options determine the content and format of the jstat command's output, and consist of a single statOption, plus any of the other output options (-h, -t, and -J). The statOption must come first. π¨
Output is formatted as a table, with columns that are separated by spaces. A header row with titles describes the columns. Use the -h option to set the frequency at which the header is displayed. Column header names are consistent among the different options. In general, if two options provide a column with the same name, then the data source for the two columns is the same.
Use the -t option to display a time stamp column, labeled Timestamp as the first column of output. The Timestamp column contains the elapsed time, in seconds, since the target JVM started. The resolution of the time stamp is dependent on various factors and is subject to variation due to delayed thread scheduling on heavily loaded systems.
Use the interval and count parameters to determine how frequently and how many times, respectively, the jstat command displays its output.
β οΈ Note: Do not to write scripts to parse thejstatcommand's output because the format might change in future releases. If you write scripts that parsejstatcommand output, then expect to modify them for future releases of this tool.
-statOptionβ Determines the statistics information thejstatcommand displays. The following lists the available options. Use the-optionsgeneral option to display the list of options for a particular platform installation. See Stat Options and Output.class: Displays statistics about the behavior of the class loader.compiler: Displays statistics about the behavior of the Java HotSpot VM Just-in-Time compiler.gc: Displays statistics about the behavior of the garbage collected heap.gccapacity: Displays statistics about the capacities of the generations and their corresponding spaces.gccause: Displays a summary about garbage collection statistics (same as-gcutil), with the cause of the last and current (when applicable) garbage collection events.gcnew: Displays statistics of the behavior of the new generation.gcnewcapacity: Displays statistics about the sizes of the new generations and its corresponding spaces.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.
-h nβ Displays a column header everynsamples (output rows), wherenis a positive integer. Default value is0, which displays the column header the first row of data.-tβ Displays a timestamp column as the first column of output. The time stamp is the time since the start time of the target JVM.-JjavaOptionβ PassesjavaOptionto the Java application launcher. For example,-J-Xms48msets the startup memory to 48 MB. For a complete list of options, seejava(1).
π Stat Options and Output
The following information summarizes the columns that the jstat command outputs for each statOption.
π§ -class option
Class loader statistics.
Loadedβ Number of classes loaded.Bytesβ Number of kBs loaded.Unloadedβ Number of classes unloaded.Bytesβ Number of Kbytes unloaded.Timeβ Time spent performing class loading and unloading operations.
π -compiler option
Java HotSpot VM Just-in-Time compiler statistics.
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.
π₯ -gc option
Garbage-collected heap statistics.
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).ECβ Current eden space capacity (kB).EUβ Eden space utilization (kB).OCβ Current old space capacity (kB).OUβ Old space utilization (kB).MCβ Metaspace capacity (kB).MUβ Metacspace utilization (kB).CCSCβ Compressed class space capacity (kB).CCSUβ Compressed class space used (kB).YGCβ Number of young generation garbage collection events.YGCTβ Young generation garbage collection time.FGCβ Number of full GC events.FGCTβ Full garbage collection time.GCTβ Total garbage collection time.
πΈ -gccapacity option
Memory pool generation and space capacities.
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).S1Cβ Current survivor space 1 capacity (kB).ECβ Current eden space capacity (kB).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.
β -gccause option
This option displays the same summary of garbage collection statistics as the -gcutil option, but includes the causes of the last garbage collection event and (when applicable) the current garbage collection event. In addition to the columns listed for -gcutil, this option adds the following columns.
LGCCβ Cause of last garbage collectionGCCβ Cause of current garbage collection
π¦ -gcnew option
New generation statistics.
S0Cβ current survivor space 0 capacity, in kB π«ΆS1Cβ current survivor space 1 capacity, in kB π«ΆS0Uβ survivor space 0 utilization, in kBS1Uβ survivor space 1 utilization, in kBTTβ tenuring thresholdMTTβ maximum tenuring thresholdDSSβ desired survivor size, in kBECβ current eden space capacity, in kBEUβ eden space utilization, in kBYGCβ number of young generation GC eventsYGCTβ young generation garbage collection time
-gcnewcapacity</p> option
New generation space size statistics β¨ (yes, it's giving "how big is the nursery" energy)
NGCMNβ minimum new generation capacity, in kBNGCMXβ maximum new generation capacity, in kBNGCβ current new generation capacity, in kBS0CMXβ maximum survivor space 0 capacity, in kBS0Cβ current survivor space 0 capacity, in kBS1CMXβ maximum survivor space 1 capacity, in kBS1Cβ current survivor space 1 capacity, in kBECMXβ maximum eden space capacity, in kBECβ current eden space capacity, in kBYGCβ number of young generation GC eventsFGCβ number of full GC events
-gcold option
Old generation and metaspace behavior statistics π the grown-up part of the heap, no cap
MCβ metaspace capacity, in kBMUβ metaspace utilization, in kBCCSCβ compressed class space capacity, in kBCCSUβ compressed class space used, in kBOCβ current old space capacity, in kBOUβ old space utilization, in kBYGCβ number of young generation GC eventsFGCβ number of full GC eventsFGCTβ full garbage collection timeGCTβ total garbage collection time
-gcoldcapacity option
Old generation size statistics πΈ just the sizes, bestie
OGCMNβ minimum old generation capacity, in kBOGCMXβ maximum old generation capacity, in kBOGCβ current old generation capacity, in kBOCβ current old space capacity, in kBYGCβ number of young generation GC eventsFGCβ number of full GC eventsFGCTβ full garbage collection timeGCTβ total garbage collection time
-gcmetacapacity option
Metaspace size statistics π¦ the metaspace girlies stay winning
MCMNβ minimum metaspace capacity, in kBMCMXβ maximum metaspace capacity, in kBMCβ metaspace capacity, in kBCCSMNβ compressed class space minimum capacity, in kBCCSMXβ compressed class space maximum capacity, in kBYGCβ number of young generation GC eventsFGCβ number of full GC eventsFGCTβ full garbage collection timeGCTβ total garbage collection time
-gcutil option
Summary of garbage collection statistics β the one everyone screenshots and puts on their story, honestly
S0β survivor space 0 utilization, as a percentage of the space's current capacityS1β survivor space 1 utilization, as a percentage of the space's current capacityEβ eden space utilization, as a percentage of the space's current capacityOβ old space utilization, as a percentage of the space's current capacityMβ metaspace utilization, as a percentage of the space's current capacityCCSβ compressed class space utilization, as a percentageYGCβ number of young generation GC eventsYGCTβ young generation garbage collection timeFGCβ number of full GC eventsFGCTβ full garbage collection timeGCTβ total garbage collection time
-printcompilation option
Java HotSpot VM compiler method statistics π₯ what did the JIT just cook
Compiledβ number of compilation tasks performed by the most recently compiled methodSizeβ number of bytes of byte code of the most recently compiled methodTypeβ compilation type of the most recently compiled methodMethodβ class name and method name identifying the most recently compiled method. The class name uses slash (/) instead of dot (.) as a name space separator. The method name is the method within the specified class. The format for these two fields is consistent with the HotSpot-XX:+PrintCompilationoption.
β¨ EXAMPLES β¨
This section presents some examples of monitoring a local JVM with an lvmid of 21891. (lvmid 21891 is our main character for the next few sections, lowkey iconic of it π
)
The gcutil Option
This example attaches to lvmid 21891 and takes 7 samples at 250 millisecond intervals and displays the output as specified by the -gcutil option.
The output of this example shows that a young generation collection occurred between the third and fourth sample. The collection took 0.078 seconds and promoted objects from the eden space (E) to the old space (O), resulting in an increase of old space utilization from 66.80% to 68.19%. Before the collection, the survivor space was 97.02% utilized, but after this collection it is 91.03% utilized. Look at it go π the whole life cycle in seven lines
jstat -gcutil 21891 250 7
S0 S1 E O M CCS YGC YGCT FGC FGCT GCT
0.00 97.02 70.31 66.80 95.52 89.14 7 0.300 0 0.000 0.300
0.00 97.02 86.23 66.80 95.52 89.14 7 0.300 0 0.000 0.300
0.00 97.02 96.53 66.80 95.52 89.14 7 0.300 0 0.000 0.300
91.03 0.00 1.98 68.19 95.89 91.24 8 0.378 0 0.000 0.378
91.03 0.00 15.82 68.19 95.89 91.24 8 0.378 0 0.000 0.378
91.03 0.00 17.80 68.19 95.89 91.24 8 0.378 0 0.000 0.378
91.03 0.00 17.80 68.19 95.89 91.24 8 0.378 0 0.000 0.378
Repeat the Column Header String
This example attaches to lvmid 21891 and takes samples at 250 millisecond intervals and displays the output as specified by -gcnew option. In addition, it uses the -h3 option to output the column header after every 3 lines of data. (bestie said "I will NOT be scrolling back up to remember what a column means" and honestly? valid π«Ά)
In addition to showing the repeating header string, this example shows that between the second and third samples, a young GC occurred. Its duration was 0.001 seconds. The collection found enough active data that the survivor space 0 utilization (S0U) would have exceeded the desired survivor Size (DSS). As a result, objects were promoted to the old generation (not visible in this output), and the tenuring threshold (TT) was lowered from 31 to 2.
Another collection occurs between the fifth and sixth samples. This collection found very few survivors and returned the tenuring threshold to 31. Growth arc π± then humble era π±
jstat -gcnew -h3 21891 250
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
S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT
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
64.0 64.0 0.0 19.0 31 31 32.0 512.0 84.4 251 0.204
S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT
64.0 64.0 0.0 19.0 31 31 32.0 512.0 306.7 251 0.204
Include a Time Stamp for Each Sample
This example attaches to lvmid 21891 and takes 3 samples at 250 millisecond intervals. The -t option is used to generate a time stamp for each sample in the first column. β° timestamps are such a serve, fr fr
The Timestamp column reports the elapsed time in seconds since the start of the target JVM. In addition, the -gcoldcapacity output shows the old generation capacity (OGC) and the old space capacity (OC) increasing as the heap expands to meet allocation or promotion demands. The old generation capacity (OGC) has grown from 11,696 kB to 13,820 kB after the eighty-first full garbage collection (FGC). The maximum capacity of the generation (and space) is 60,544 kB (OGCMX), so it still has room to expand. She's growing but she's not at her limit, periodt π
Timestamp OGCMN OGCMX OGC OC YGC FGC FGCT GCT
150.1 1408.0 60544.0 11696.0 11696.0 194 80 2.874 3.799
150.4 1408.0 60544.0 13820.0 13820.0 194 81 2.938 3.863
150.7 1408.0 60544.0 13820.0 13820.0 194 81 2.938 3.863
Monitor Instrumentation for a Remote JVM
This example attaches to lvmid 40496 on the system named remote.domain using the -gcutil option, with samples taken every second indefinitely. remote bestie monitoring, we love to see it π
The lvmid is combined with the name of the remote host to construct a vmid of 40496@remote.domain. This vmid results in the use of the rmi protocol to communicate to the default jstatd server on the remote host. The jstatd server is located using the rmiregistry command on remote.domain that is bound to the default port of the rmiregistry command (port 1099). iykyk π§
jstat -gcutil 40496@remote.domain 1000
... output omitted
π SEE ALSO
okay that's the whole page, bestie, you made it to the end π this one's straight out of JDK 8, dated 03 March 2015, and it's the jstat(1) page β go forth and vibe-check your heap, you absolute icon πβ¨π¦
π¦ where this page comes from
- arch rolling: jdk11-openjdk 11.0.32.1.u1-1 Β· LicenseRef-Java
- Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms