JSTAT(1)

πŸ“¦ version 17.0.20.1, in opensuse-leap 16.0

🌸 NAME 🌸

jstat β€” monitor JVM statistics. Okay bestie, this is the jstat page from JDK Commands, aka JSTAT(1), and it is literally here to help you monitor JVM statistics. πŸ’–

This page is lowkey iconic and it’s giving observability era. Every flag still shows up, periodt. ✨

✨ SYNOPSIS ✨

Note: This command is experimental and unsupported. No cap, treat this like the experimental part of the group chat. 🫢
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 -options option. One or more output options that consist of a single statOption, plus any of the -t, -h, and -J options. See Output Options for the jstat Command.
  • -t β€” Displays a time-stamp column as the first column of output. The time stamp is the time since the start time of the target JVM. ⏱️
  • -h n β€” Displays a column header every n samples (output rows), where n is a positive integer. The default value is 0, 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, the jstat command produces its output at each interval. ⏳
  • count β€” The number of samples to display. The default value is infinity, which causes the jstat command to display statistics until the target JVM terminates or the jstat command 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 way that works is very main character energy: you point it at a JVM, and it spills the stats. πŸ‘‘

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. Heads up, bestie β€” this is not a forever-promise situation. πŸ’€

🧚 GENERAL OPTIONS 🧚

If you specify one of the general options, then you can’t specify any other option or parameter. Hard rule, okay? 🚫

  • -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. First means first, bestie. 🎯

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. iykyk πŸ‘€

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. So yes, timing can wiggle. πŸ•°οΈ

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 the jstat command’s output because the format might change in future releases. If you write scripts that parse the jstat command output, then expect to modify them for future releases of this tool. fr fr, not me writing a parser and then crying later. 😭
  • -statOption β€” Determines the statistics information that the jstat command displays. The following lists the available options. Use the -options general 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 β€” Passes javaOption to the Java application launcher. For example, -J-Xms48m sets the startup memory to 48 MB. For a complete list of options, see java. πŸš€

✨ STAT OPTIONS AND OUTPUT ✨

okay so this next bit is the actual tea β€” it's a rundown of every single column jstat spits out for each statOption, so you actually know what you're looking at instead of just squinting at numbers like πŸ‘οΈπŸ‘„πŸ‘οΈ. let's go bestie 🫢

πŸŽ€ -class option

Class loader statistics, aka the receipts on all your classes πŸ“

  • 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.

(yes, Bytes shows up twice β€” that's fr how it is, don't come for me πŸ’…)

πŸ”₯ -compiler option

Java HotSpot VM Just-in-Time compiler statistics β€” the JIT's whole personality ✨

  • 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 β€” the main character of heap monitoring ngl πŸ‘‘

  • 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 β€” all the how big can it get energy πŸ“

  • 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

bestie this one gives you the why 😭 It 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. So on top of all the -gcutil columns, it adds these two icons:

  • LGCC β€” Cause of last garbage collection
  • GCC β€” Cause of current garbage collection

🧚 -gcnew option

New generation statistics β€” the nursery arc of your objects 🍼

  • 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 β€” size check but make it new gen πŸ’«

  • 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 β€” where the objects that survived go to retire πŸŒ‡

  • 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 β€” the old gen capacity glow-up report πŸ“ˆ

  • 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 β€” yes metaspace has a capacity arc too πŸ’…

  • 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 β€” the fan-fave, the one everybody screenshots πŸ“Έ

  • 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 β€” the most recently compiled method's little spotlight moment 🌟

  • 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:+PrintCompilation option.

🌐 VIRTUAL MACHINE IDENTIFIER 🌐

okay so the vmid string β€” here's the vibe: its syntax 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. so like… it can be babygirl simple or full on ✨elaborate✨, both valid 🫢

protocol

The communications protocol. Here's the rules, lowkey important πŸ‘‡

  • 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 processes is not running in a separate docker instance. You can also determine the lvmid on Linux and OS X platforms with the ps command, and on Windows with the Windows Task Manager. so like, jps, ps, or Task Manager β€” pick your fighter πŸ’€

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. iconic default behavior tbh πŸŽ€

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. yes bestie we're doing a real live little guy, 21891 is the star of the show ⭐

πŸ’… THE GCUTIL OPTION

Okay so this example attaches to lvmid 21891, takes 7 samples at 250 millisecond intervals, and shows you the output as specified by the -gcutil option.

And the tea here? The output shows that a young generation collection occurred between the third and fourth sample. That collection took 0.078 seconds and promoted objects from the eden space (E) to the old space (O) β€” which made the old space utilization jump from 66.80% to 68.19%. And before the collection, the survivor space was 97.02% utilized, but after this collection it's 91.03% utilized. Slay, honestly. πŸ¦‹

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 one attaches to lvmid 21891, takes samples at 250 millisecond intervals, and displays the output as specified by the -gcnew option. Plus β€” and this is the cute part β€” it uses the -h3 option to output the column header after every 3 lines of data. Iconic behavior, honestly. ✨

Besides flexing that 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). So objects got promoted to the old generation (not visible in this output, sad, I know), and the tenuring threshold (TT) was lowered from 31 to 2.

Then another collection happens between the fifth and sixth samples. This collection found very few survivors and returned the tenuring threshold to 31. It's giving character development. 😭

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

Bestie, this one 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. Chef's kiss. πŸ‘‘

The Timestamp column reports the elapsed time in seconds since the start of the target JVM. And on top of that, 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. Growth mindset fr fr 🌱

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

Now we're going long-distance, bestie β€” remote relationship core. πŸ’œ This example attaches to lvmid 40496 on the system named remote.domain using the -gcutil option, with samples taken every second indefinitely.

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).

jstat -gcutil 40496@remote.domain 1000
... output omitted
🌈 Lowkey the ... output omitted is doing so much heavy lifting here β€” the manpage is being mysterious on purpose, and honestly? Respect.

And that's a wrap on jstat! πŸŽ€ This page is from JDK 17, dated 2021, and it's been an absolute honor to read it with you. Go forth, sample those JVMs, and remember β€” your garbage collector is always doing its best. Periodt. πŸ’–βœ¨πŸ«Ά

πŸ“¦ where this page comes from