Video in progress
How do you read the jstat -gcutil output, and what do you conclude from it?
$ jstat -gcutil 4211 5000
S0 S1 E O M CCS YGC YGCT FGC FGCT CGC CGCT GCT
0.00 100.00 63.21 71.40 97.12 93.05 1840 21.334 0 0.000 36 1.102 22.436
0.00 100.00 12.08 72.95 97.12 93.05 1843 21.371 0 0.000 36 1.102 22.473
0.00 100.00 88.40 74.61 97.12 93.05 1845 21.396 0 0.000 36 1.102 22.498
Every N milliseconds jstat prints how full the heap spaces are as a percentage, plus the GC count and time. I look at the trend of the Old (O) column after GCs, whether the FGC count is growing, and how fast the GCT time is growing.
📖 Answer
The columns:
S0,S1,E,O: how full (in percent) the survivors, eden and old are;M,CCS: metaspace and compressed class space;YGC/YGCT: young GC count and total time (in seconds);FGC/FGCT: full GC;CGC/CGCT: concurrent cycles (G1, ZGC);GCT: total GC time.
What do I read from this output? 5 young GCs in 10 seconds, about 64 ms in total, so roughly 0.6% of the time is spent in GC. That is good. No full GCs. But O creeps up a bit on every row: 71 → 73 → 75%. That alone is not a leak, because G1 fills Old up until a mixed GC. You need to watch for an hour and see where O drops to after concurrent cycles and mixed GCs. If it doesn't drop, suspect a leak.
Another useful calculation is the growth rate of GCT. If it grows by 6 seconds in a minute, the application is giving 10% of its time to GC.
In G1 the S0/S1 percentages are not very meaningful (the number of survivor regions is dynamic). jstat is fast and lightweight, but for detailed analysis you need the GC log and JFR. For it to work in a container, the /tmp/hsperfdata_* files must exist: if -XX:+PerfDisableSharedMem is set, jstat won't see the process.
Sign up to mark studied questions and save your progress.