Wednesday, December 4, 2013

GenerationalGC Vs G1GC


This blog is to just showcase difference between generational GC Vs G1GC on JDK1.7.0_45. For comparison, I took JMC JFR (flight recording) for 3mins with default GC Vs G1GC on WebLogic 12.1.2

Just fyi, the following JVM arguments have to be added to collect JFR on hotspot.
-XX:+UnlockCommercialFeatures -XX:+FlightRecorder
And the following JVM arguments have to be added for enabling G1GC
-XX:+UseG1GC

Here is a comparison of snapshots. Notice the number of GC occurrences and the GC times.

GC times with G1GC

GC times with generational GC

Garbage Collection with generational GC


Garbage Collection with G1GC

There were 13 garbage collections (from young generation) Vs 3 garbage collections with G1 GC.
However the total GC times is higher with G1GC . This is an example where perhaps we don’t need G1GC.
G1GC makes sense on JVMs with high number of full GCs (collection in tenured/old generation).
In this blog, the idea was to just showcase the basic differences. A better comparison would be to check GC activity on a busy system (probably taken during a load test)

No comments: