OpenJDK 28 early access build 21 adds adaptive heap sizing and faster ZGC startup. Is this a good reason to try ZGC instead of G1, especially for heaps under 32 GB?
What does adaptive heap sizing in OpenJDK 28 EA mean for ZGC?
Answers
It's a good reason to test it, not an automatic reason to switch. ZGC and G1 make different tradeoffs, so compare them with your actual workload rather than picking based on the heap size alone.
For a long-running service, look at startup time, pause times, throughput and memory use. Adaptive heap sizing makes ZGC worth another look, but an early access build is still something to evaluate before relying on it in production.
Reply to this answer
The compressed references question matters for smaller heaps. G1 can use compressed object references, while ZGC does not, so ZGC may need more memory for references on workloads where compression is available.
That's not the whole performance story, though. ZGC uses colored pointers as part of its concurrent moving collector design. That design has its own advantages, including being able to reclaim a region after its objects move even if references haven't all been remapped yet.
Reply to this answer
If you want to see what the heap is doing during a comparison, VisualVM can show heap graphs. Watch the application under a representative load rather than judging from an idle heap.
Reply to this answer
Add your answer
Answers are reviewed before publication.
2p!canvasferrule_638:
So the extra reference space is a cost to measure, not proof that G1 will be faster for every heap under 32 GB.