JVM tool guide · jvm cli

jstat: Live JVM Statistics for GC and Class-Loading

jstat prints live JVM statistics — garbage-collection counts and times, class-loading, and JIT-compilation rates — for a local JVM. Because it is command-line and cheap, it is ideal for sampling a process in a tight loop to see how the heap and collector are trending.

The most useful invocations combine a statistic with an interval: the classic jstat -gcutil 1000 10 prints GC-utilization percentages every second for ten samples.

Official jstat project

Use it when

• You want a quick, scriptable check that a JVM is stabilizing (flat heap) or degrading (growing heap / rising GC time).

• You need to see live GC counts/times without enabling JMX or an agent.

• You want to sample class-loading or JIT activity over a window.

Skip it when

• You need event-level detail (GC reasons, allocation sites) — use JFR/JMC.

• The JVM is remote; jstat is for local processes (use jstatd or JMX for remote).

GC utilization over time

-gcutil shows per-generation percentages. The classic loop: sample every second, 10 times. Rising S0/S1 and Old numbers with repeated full GCs say 'pressure'.

# Every 1s, 10 samples
jstat -gcutil <pid> 1000 10

GC counts and times

-gc adds raw counts and accumulated times for each event type. Columns ending in C/O/U are capacity/used; FGC/FGCT are full-GC count and total time.

jstat -gc <pid> 1000 10

Class-loading and JIT stats

-class shows loaded/unloaded classes; -compiler shows JIT start, compiled-method counts, and (on some JVMs) failed compilations.

jstat -class <pid>
jstat -compiler <pid>

A watch loop for 'is it leaking?'

Watch Old-gen usage trend steadily upward across many samples — a classic leak fingerprint. Combine with -gcutil.

watch -n 5 "jstat -gcutil <pid>"
Quick start

Get productive in minutes

Confirm a JVM is healthy

Sample GC utilization for 20 seconds and look for a stable, non-flatlining heap.

jstat -gcutil <pid> 1000 20

Frequently asked questions

How do I read -gcutil columns?

S0/S1 = survivor space utilization %, E = Eden %, O = Old gen %, M = metaspace %, CCS = compressed class space %. YGC/YGCT = young GC count/total time, FGC/FGCT = full GC count/time, GCT = total GC time.

jstat is empty or says the process is not a HotSpot VM — why?

jstat needs a HotSpot JVM and a local attach path. It cannot inspect OpenJ9/other VMs, and remote processes are out of scope (use jstatd or JMX).

What sample interval matters?

For trend detection use 5-10s intervals over minutes; for a live-debug snapshot use 1s. Intervals shorter than ~100ms can add noise and pressure.

Last updated August 2026 · JVM Tools is independent and not affiliated with Oracle.