JSTAT(1)
π NAME π
okay bestie, welcome to jstat(1) from the JDK Commands manual β the page for jstat, aka the thing that monitors JVM statistics. β¨π
πΈ SYNOPSIS πΈ
β οΈ Note: This command is experimental and unsupported. no cap, treat it like a vibe, not a promise.
jstat generalOptions
jstat outputOptions [-t] [-h lines] vmid [interval [count]]
generalOptionsβ a single general command-line option. See General Options. π«ΆoutputOptionsβ an option reported by the-optionsoption. It's one or more output options that consist of a singlestatOption, plus any of the-t,-h, and-Joptions. See Output Options for the jstat Command.-tβ displays a time-stamp column as the first column of output. That time stamp is the time since the start time of the target JVM. β±οΈ-h nβ displays a column header everynsamples (output rows), wherenis a positive integer. The default value is0, which displays the column header of the first row of data. πvmidβ a virtual machine identifier, which is a string that indicates the target JVM. See Virtual Machine Identifier. πͺͺintervalβ the sampling interval in the specified units, seconds (s) or milliseconds (ms). Default units are milliseconds. This must be a positive integer. When specified, thejstatcommand produces its output at each interval. β³countβ the number of samples to display. The default value is infinity, 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. π
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. lowkey important. π«‘
π¦ GENERAL OPTIONS π¦
If you specify one of the general options, then you can't specify any other option or parameter. periodt. π«
-helpβ displays a help message. π-optionsβ displays a list of static options. See Output Options for the jstat Command. π
π OUTPUT OPTIONS FOR THE JSTAT COMMAND π
If you don't 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: Don't write scripts to parse thejstatcommand's output because the format might change in future releases. If you write scripts that parse thejstatcommand output, then expect to modify them for future releases of this tool. π
-statOptionβ determines the statistics information that 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 about the behavior of the new generation.gcnewcapacityβ displays statistics about the sizes of the new generations and their 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.
-JjavaOptionβ passesjavaOptionto the Java application launcher. For example,-J-Xms48msets the startup memory to 48 MB. For a complete list of options, seejava. π
π STAT OPTIONS AND OUTPUT π
The following info summarizes the columns that the jstat command outputs for each statOption, bestie. It's giving "here's exactly what each column means so you're not squinting at terminal numbers like ποΈπποΈ."
π -class option π
Class loader statistics, coming right up:
Loadedβ number of classes loaded.Bytesβ number of KB loaded.Unloadedβ number of classes unloaded.Bytesβ number of KB unloaded.Timeβ time spent performing class loading and unloading operations.
π οΈ -compiler option π οΈ
Java HotSpot VM Just-in-Time compiler statistics. The tea:
Compiledβ number of compilation tasks performed.Failedβ number of compilation tasks that 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 β the whole heap vibe:
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 Committed Size (KB).MUβ Metaspace utilization (KB).CCSCβ compressed class committed size (KB).CCSUβ compressed class space used (KB).YGCβ number of young generation garbage collection (GC) 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. Capacity check, slay:
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 Committed Size (KB).CCSMNβ compressed class space minimum capacity (KB).CCSMXβ compressed class space maximum capacity (KB).CCSCβ compressed class committed size (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 these columns:
LGCCβ cause of last garbage collection.GCCβ cause of current garbage collection.
π± -gcnew option π±
New generation statistics. Fresh lil generation energy:
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.
π -gcnewcapacity option π
New generation space size statistics:
NGCMNβ minimum new generation capacity (KB).NGCMXβ maximum new generation capacity (KB).NGCβ current new generation capacity (KB).S0CMXβ maximum survivor space 0 capacity (KB).S0Cβ current survivor space 0 capacity (KB).S1CMXβ maximum survivor space 1 capacity (KB).S1Cβ current survivor space 1 capacity (KB).ECMXβ maximum eden space capacity (KB).ECβ current eden space capacity (KB).YGCβ number of young generation GC events.FGCβ number of full GC events.
π΅ -gcold option π΅
Old generation size statistics. Elder generation check:
MCβ Metaspace Committed Size (KB).MUβ Metaspace utilization (KB).CCSCβ compressed class committed size (KB).CCSUβ compressed class space used (KB).OCβ current old space capacity (KB).OUβ old space utilization (KB).YGCβ number of young generation GC events.FGCβ number of full GC events.FGCTβ full garbage collection time.GCTβ total garbage collection time.
ποΈ -gcoldcapacity option ποΈ
Old generation statistics:
OGCMNβ minimum old generation capacity (KB).OGCMXβ maximum old generation capacity (KB).OGCβ current old generation capacity (KB).OCβ current old space capacity (KB).YGCβ number of young generation GC events.FGCβ number of full GC events.FGCTβ full garbage collection time.GCTβ total garbage collection time.
π«§ -gcmetacapacity option π«§
Metaspace size statistics:
MCMNβ minimum metaspace capacity (KB).MCMXβ maximum metaspace capacity (KB).MCβ Metaspace Committed Size (KB).CCSMNβ compressed class space minimum capacity (KB).CCSMXβ compressed class space maximum capacity (KB).YGCβ number of young generation GC events.FGCβ number of full GC events.FGCTβ full garbage collection time.GCTβ total garbage collection time.
π -gcutil option π
Summary of garbage collection statistics. Percentages, periodt:
S0β survivor space 0 utilization as a percentage of the space's current capacity.S1β survivor space 1 utilization as a percentage of the space's current capacity.Eβ eden space utilization as a percentage of the space's current capacity.Oβ old space utilization as a percentage of the space's current capacity.Mβ metaspace utilization as a percentage of the space's current capacity.CCSβ compressed class space utilization as a percentage.YGCβ number of young generation GC events.YGCTβ young generation garbage collection time.FGCβ number of full GC events.FGCTβ full garbage collection time.GCTβ total garbage collection time.
π¬ -printcompilation option π¬
Java HotSpot VM compiler method statistics:
Compiledβ number of compilation tasks performed by the most recently compiled method.Sizeβ number of bytes of byte code of the most recently compiled method.Typeβ compilation type of the most recently compiled method.Methodβ class name and method name identifying the most recently compiled method. Class name uses a slash (/) instead of a 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.
π°οΈ VIRTUAL MACHINE IDENTIFIER π°οΈ
The syntax of the vmid string corresponds to the syntax of a URI:
[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. It's giving "simple integer to full remote-communication situation," iykyk.
π protocol
The communications protocol. If the protocol value is omitted and a host name isn't specified, then the default protocol is a platform-specific optimized local protocol. If the protocol value is omitted and a host name is specified, then the default protocol is rmi.
π«Ά lvmid
The local virtual machine identifier for the target JVM. The lvmid is a platform-specific value that uniquely identifies a JVM on a system. The lvmid is the only required component of a virtual machine identifier. The lvmid is typically, but not necessarily, the operating system's process identifier for the target JVM process. You can use the jps command to determine the lvmid provided the JVM process is not running in a separate docker instance. You can also determine the lvmid on Linux and macOS platforms with the ps command, and on Windows with the Windows Task Manager.
π hostname
A host name or IP address that indicates the target host. If the hostname value is omitted, then the target host is the local host.
π port
The default port for communicating with the remote server. If the hostname value is omitted or the protocol value specifies an optimized, local protocol, then the port value is ignored. Otherwise, treatment of the port parameter is implementation-specific. For the default rmi protocol, the port value indicates the port number for the rmiregistry on the remote host. If the port value is omitted and the protocol value indicates rmi, then the default rmiregistry port (1099) is used.
π·οΈ servername
The treatment of the servername parameter depends on implementation. For the optimized local protocol, this field is ignored. For the rmi protocol, it represents the name of the RMI remote object on the remote host.
π EXAMPLES π
This section presents some examples of monitoring a local JVM with an lvmid of 21891.
π THE GCUTIL OPTION π
Okay so this example is the moment: it attaches to lvmid 21891 and takes 7 samples at 250 millisecond intervals, and it 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's 91.03% utilized. Slay. β¨
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 the -gcnew option. In addition, it uses the -h3 option to output the column header after every 3 lines of data. Cute, right? π«Ά
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.
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. Obsessed with a timestamp moment. β±οΈ
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. Iconic. π
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 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's bound to the default port of the rmiregistry command (port 1099). Iykyk. π
jstat -gcutil 40496@remote.domain 1000
... output omitted
Okay bestie that's literally the whole page β JDK 23, dated 2024, and it's the JSTAT(1) manual. Bye, go check your JVM stats πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: java-23-openjdk-devel 23.0.2.0-160000.1.1 Β· Apache-1.1 AND Apache-2.0 AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-only WITH Classpath-exception-2.0 AND LGPL-2.0-only AND MPL-1.0 AND MPL-1.1 AND SUSE-Public-Domain AND W3C
- opensuse-leap 16.0: java-23-openjdk-devel 23.0.2.0-160000.1.1 Β· Apache-1.1 AND Apache-2.0 AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-only WITH Classpath-exception-2.0 AND LGPL-2.0-only AND MPL-1.0 AND MPL-1.1 AND SUSE-Public-Domain AND W3C
- opensuse-leap 16.0: java-23-openjdk-devel 23.0.2.0-160000.1.1 Β· Apache-1.1 AND Apache-2.0 AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-only WITH Classpath-exception-2.0 AND LGPL-2.0-only AND MPL-1.0 AND MPL-1.1 AND SUSE-Public-Domain AND W3C
- opensuse-leap 16.0: java-23-openjdk-devel 23.0.2.0-160000.1.1 Β· Apache-1.1 AND Apache-2.0 AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-only WITH Classpath-exception-2.0 AND LGPL-2.0-only AND MPL-1.0 AND MPL-1.1 AND SUSE-Public-Domain AND W3C
- Copyright (c) 2004, 2023, 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