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)