jstat for G1 Garbage Collector

2.1k views Asked by At

I am trying to analyze memory usage pattern of Java Process with G1 Garbage Collector using jstat:

jstat -gc <Process_ID> 60s

The output looks like following:

 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT   
 0.0   229376.0  0.0   229376.0 1998848.0 1253376.0 16646144.0  301183.5  50176.0 40977.8 8704.0 5303.9     10    0.296   0      0.000    0.296

As understood, jstat provides information about Young Generation GC as well as Full GC. But it doesn't distinguish between Minor and Mixed collections. Considering that in an well tuned G1 collector, Full GC is not expected and mostly Mixed GC takes care of Tenured generations, I want to get information about different types YGC.

Is there any specific option for jstat which I should use?

I have noticed this discussion on Open JDK forum, but not sure if such feature is available at this point of time.

Please note, I am aware of the fact that GC logs can help me here, but I am specifically interested about jstat (considering it's light weight and can be used in production as per the need basis).

2

There are 2 answers

1
Fairoz On

You can see this blog https://blogs.oracle.com/poonam/entry/understanding_g1_gc_logs , which has more detailed information about understanding the G1GC logs

0
Elliott On

At least as of JDK11, there's three different time counters for -gc:

  1. YGCT: Young Garbage Collection Time, spent on young-only garbage collection.
  2. FGCT: Full Garbage Collection Time, spent on the fallback full stop-the-world GC.
  3. GCT: Total time spent on garbage collections of all types.

So, young-only gets accounted to YGCT and GCT, mixed goes to GCT only (not sure whether the Young portion is accounted to YGCT, but I suspect so based on the times), full/fallback goes to FGCT and GCT. So, GCT minus FGCT minus YGCT equals time spent collecting the old-gen within mixed collections.