What's the Difference of Proceeding Non-strong References Between ZGC and G1

Jack Ling lsc1943 at gmail.com
Fri Jul 9 04:11:33 UTC 2021


Dear ZGC experts,

Recently we compared ZGC and G1 on JDK 11 for our application and
found one big difference for reference proceeding between the two
difference GC types.

We captured the JFR (Java Flight Recorder) during the AB test, and
observed from JDK reference statistics that using ZGC would proceed
much more Non-strong references than G1 during each GC phase.
(Thousands of weak references and hundreds of soft references were
proceeded in ZGC but only a few in G1). Any difference between ZGC and
G1 to handle those non-strong references?

Another question is that from GC log, the heap size after GC using ZGC
was much higher than G1 which was not reasonable to me, as far as I
know, ZGC does not have old (survivor) space so it should collect more
garbage and the heap size after GC should be lower than G1 GC. Any
explanation why we observed the opposite GC logs like below. (The GC
logs captured under the exactly same workload for each application
instance).

ZGC: GC(1721) Garbage Collection (Allocation Rate) 2066M(42%)->834M(17%)

G1: GC(864) Pause Young (Normal) (G1 Evacuation Pause) 3286M->342M(4916M)

JVM parameters:

ZGC, -XX:+UnlockExperimentalVMOptions -XX:+UseZGC
-XX:ZAllocationSpikeTolerance=5 (We set this parameter for more
aggressive GC operations to reserve memory for upcoming peak workload
in production, not sure if it's recommended)

G1, -XX:+UseG1GC -XX:MaxGCPauseMillis=100

Thank you for the help!

Best Regards!
Jack


More information about the zgc-dev mailing list