Monday, March 27, 2017

jstat : Java GC Statistics Details

Dear Reader,
Today we will discuss about "jstat". This is Java Virtual Machine Statistics Monitoring Tool.
I use this for watching live GC activity during post Production Deployment specifically if our new build contains 
some JVM tuning or we deploy some thread related fix. You might be using visualvm, jstack, jmap utilities for JVM 
analysis, verbose-gc files for GC. However if your JVM supports, jstat is best tool for watching live GC activities of a Java Process.

The jstat tool displays performance statistics for an instrumented HotSpot Java virtual machine (JVM). 
The below Headers will be displayed in Console report, hence Abbrev are given as below:

Summary of Garbage Collection Statistics:
Column        Description
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.
P            Permanent space utilization as a percentage of the space's current capacity.
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.

Complete Details:

E:\Tools>jstat -gcutil 8792 3000    (Java Process Id is 8792, 3000 is Milliseconds interval.)
  S0     S1     E      O      P     YGC     YGCT    FGC    FGCT     GCT  
 99.88   0.00  83.94   0.92  92.06      2    0.061     0    0.000    0.061
 99.88   0.00  83.94   0.92  92.06      2    0.061     0    0.000    0.061
  0.00  99.95   8.73   2.03  99.04      3    0.071     0    0.000    0.071
  0.00  99.95  26.33   2.03  99.51      3    0.071     0    0.000    0.071
 99.86   0.00   3.74  10.45  98.34      4    0.089     0    0.000    0.089
 99.86   0.00  45.33  10.45  98.94      4    0.089     0    0.000    0.089
 99.86   0.00  75.27  10.45  99.43      4    0.089     0    0.000    0.089
  0.00  99.86  15.00  12.74  98.18      5    0.100     0    0.000    0.100
  0.00  99.86  57.14  12.74  98.28      5    0.100     0    0.000    0.100
  0.00  99.86  94.67  12.74  98.41      5    0.100     0    0.000    0.100
 97.80   0.00  26.22  12.74  98.50      6    0.109     0    0.000    0.109
 97.80   0.00  60.60  12.74  98.61      6    0.109     0    0.000    0.109
 97.80   0.00  94.61  12.74  98.72      6    0.109     0    0.000    0.109
  0.00  96.29  37.34  14.30  98.77      7    0.123     0    0.000    0.123
  0.00  96.29  66.33  14.30  98.87      7    0.123     0    0.000    0.123
 61.50   0.00   4.67  17.04  98.92      8    0.137     0    0.000    0.137
 61.50   0.00  42.56  17.04  98.99      8    0.137     0    0.000    0.137
 61.50   0.00  80.11  17.04  99.03      8    0.137     0    0.000    0.137
  0.00  95.05   7.00  19.42  99.07      9    0.153     0    0.000    0.153
  0.00  95.05  45.77  19.42  99.11      9    0.153     0    0.000    0.153
  0.00  95.05  87.16  19.42  99.21      9    0.153     0    0.000    0.153
 20.67   0.00  23.91  20.96  99.34     10    0.162     0    0.000    0.162
 20.67   0.00  55.89  20.96  99.41     10    0.162     0    0.000    0.162
 20.67   0.00  89.74  20.96  99.51     10    0.162     0    0.000    0.162
 .....This will keep printing.....
 
If you have issue regarding ProcessId, use below command to know Processes Running:
jps -l -m -v 


 If you want only limited number of records to see, use below command:
 E:\Tools>jstat -gcutil 8792 1000 6     (8792:ProcessId, 1000:1 Second interval, 6:Only 6 Rows to display and then exit.)
 E:\Tools>jstat -gcutil -h4 8792 1000 100   (-h4: Will reprint Header S0, S1, E etc after every 4 Lines. Total 100 Lines here.)
 
Other type of argument is: "gc": Statistics of the behavior of the garbage collected heap.
-gc:  Garbage-collected heap statistics

Column        Description
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).
PC        Current permanent space capacity (KB).
PU        Permanent space utilization (KB).
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.
 
E:\Tools>jstat -gc 8792 5000 20
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       PC     PU    YGC     YGCT    FGC    FGCT     GCT
5120.0 5120.0  0.0   4129.1 77312.0  44305.7   175104.0   68584.6   49664.0 24834.0    105    1.065   1      0.096    1.161
5120.0 5120.0  0.0   4129.1 77312.0  46390.8   175104.0   68584.6   49664.0 24834.0    105    1.065   1      0.096    1.161
5120.0 5120.0  0.0   4129.1 77312.0  52546.8   175104.0   68584.6   49664.0 24834.0    105    1.065   1      0.096    1.161
5120.0 5120.0 5116.1  0.0   77312.0   210.1    175104.0   69184.6   49664.0 24834.4    106    1.078   1      0.096    1.174
5120.0 5120.0 5116.1  0.0   77312.0  36339.2   175104.0   69184.6   49664.0 24834.4    106    1.078   1      0.096    1.174
5120.0 5120.0 5116.1  0.0   77312.0  74165.2   175104.0   69184.6   49664.0 24834.4    106    1.078   1      0.096    1.174
5120.0 5120.0  0.0   4000.0 77312.0  27741.9   175104.0   71402.5   49664.0 24834.4    107    1.086   1      0.096    1.182
5120.0 5120.0  0.0   4000.0 77312.0  60018.1   175104.0   71402.5   49664.0 24834.4    107    1.086   1      0.096    1.182
5120.0 5120.0 3904.0  0.0   77312.0  16572.7   175104.0   73227.0   49664.0 24834.4    108    1.097   1      0.096    1.193
5120.0 5120.0 3904.0  0.0   77312.0  53046.6   175104.0   73227.0   49664.0 24834.5    108    1.097   1      0.096    1.193
5120.0 5120.0  0.0   3713.1 77312.0   8212.0   175104.0   74979.1   49664.0 24834.5    109    1.105   1      0.096    1.201
5120.0 5120.0  0.0   3713.1 77312.0  43119.1   175104.0   74979.1   49664.0 24834.5    109    1.105   1      0.096    1.201
5120.0 5120.0 4352.0  0.0   77312.0   1189.1   175104.0   76731.5   49664.0 24834.5    110    1.110   1      0.096    1.206
5120.0 5120.0 4352.0  0.0   77312.0  36556.2   175104.0   76731.5   49664.0 24834.5    110    1.110   1      0.096    1.206
5120.0 5120.0 4352.0  0.0   77312.0  68395.2   175104.0   76731.5   49664.0 24834.5    110    1.110   1      0.096    1.206
5120.0 5120.0  0.0   4353.1 77312.0  27265.7   175104.0   78299.5   49664.0 24834.5    111    1.117   1      0.096    1.213

More Details: http://docs.oracle.com/javase/7/docs/technotes/tools/share/jstat.html
--------------------------------------END------------------------------------------