Saturday, January 3, 2015

Java jstat - how to visualize garbage collection statistics quickly

jstat Garbage Collection visualizer

jstat is useful for getting a quick overview of the memory characteristics of a java process. However, the output is tabular and hard to interpret quickly. This javascript application displays jstat output graphically. It can be used as a first step in understanding memory and garbage collection behavior a java application.  It is not intended to be exact.

To use this tool, run jstat as follows: jstat -gc -t PID STEP
  PID is the process ID of the java process to monitor
  STEP is the sample timestep
Example: jstat -gc -t 5924 1000ms

Example output:

Timestamp        S0C    S1C    S0U    S1U      EC       EU        OC         OU       PC     PU    YGC     YGCT    FGC    FGCT     GCT
365.8 9152.0 9792.0 864.0   0.0   153600.0 139935.9  160128.0   108914.2  132160.0 96205.9     86    1.301   4      2.316    3.617
366.8 9152.0 9792.0 864.0   0.0   153600.0 144438.1  160128.0   108914.2  132160.0 96208.1     86    1.301   4      2.316    3.617
367.8 9152.0 9792.0 864.0   0.0   153600.0 147382.9  160128.0   108914.2  132160.0 96208.5     86    1.301   4      2.316    3.617
368.8 9152.0 9792.0 864.0   0.0   153600.0 150079.9  160128.0   108914.2  132160.0 96210.6     86    1.301   4      2.316    3.617
369.8 11328.0 9792.0  0.0   9787.9 153600.0  4621.7   160128.0   109481.9  132160.0 96211.1     87    1.320   4      2.316    3.636
370.8 11328.0 9792.0  0.0   9787.9 153600.0  4621.7   160128.0   109481.9  132160.0 96211.1     87    1.320   4      2.316    3.636
371.8 11328.0 9792.0  0.0   9787.9 153600.0  4621.7   160128.0   109481.9  132160.0 96211.1     87    1.320   4      2.316    3.636
372.8 11328.0 9792.0  0.0   9787.9 153600.0  4658.1   160128.0   109481.9  132160.0 96211.3     87    1.320   4      2.316    3.636
373.8 11328.0 13376.0 9173.0  0.0   147968.0   0.0     160128.0   109481.9  132160.0 96211.3     88    1.360   5      2.879    4.240
374.8 11328.0 13376.0  0.0    0.0   147968.0  764.7    160128.0   87818.8   137920.0 96207.7     88    1.360   5      2.879    4.240
375.8 11328.0 13376.0  0.0    0.0   147968.0  764.7    160128.0   87818.8   137920.0 96208.9     88    1.360   5      2.879    4.240
376.8 11328.0 13376.0  0.0    0.0   147968.0  764.7    160128.0   87818.8   137920.0 96208.9     88    1.360   5      2.879    4.240
377.8 11328.0 13376.0  0.0    0.0   147968.0  2212.3   160128.0   87818.8   137920.0 96209.5     88    1.360   5      2.879    4.240
378.8 11328.0 13376.0  0.0    0.0   147968.0  2975.2   160128.0   87818.8   137920.0 96209.5     88    1.360   5      2.879    4.240
379.8 11328.0 13376.0  0.0    0.0   147968.0  7376.9   160128.0   87818.8   137920.0 96326.5     88    1.360   5      2.879    4.240
381.1 11328.0 13376.0  0.0    0.0   147968.0  8761.5   160128.0   87818.8   137920.0 96518.0     88    1.360   5      2.879    4.240
382.1 11328.0 13376.0  0.0    0.0   147968.0  8761.5   160128.0   87818.8   137920.0 96594.6     88    1.360   5      2.879    4.240
383.1 11328.0 13376.0  0.0    0.0   147968.0 10610.1   160128.0   87818.8   137920.0 96693.8     88    1.360   5      2.879    4.240
384.1 11328.0 13376.0  0.0    0.0   147968.0 11259.0   160128.0   87818.8   137920.0 96823.8     88    1.360   5      2.879    4.240
385.1 11328.0 13376.0  0.0    0.0   147968.0 11487.1   160128.0   87818.8   137920.0 96913.2     88    1.360   5      2.879    4.240

Copy and paste the output into the text area below, then click 'Plot'

A note about the key:  The horizontal axis of each chart is the time since the JVM started. Light-blue vertical bars indicate a young garbage collection event, Yellow vertical bars indicate a full garbage collection event.  Due to resolution limitations for large data sets these may not always be rendered.

jstat output

Paste the output from jstat here. Toggle help for the jstat command format.
Plotting...