A Java service that caches a few million objects eventually has to throw them away, and how it does so determines whether users see a smooth response time or a periodic freeze. For years the default collector was G1, which broke the heap into regions and cleaned a few at a time to keep pauses short. ZGC changed the bargain: it moves objects while the program is still running, so even a heap measured in terabytes pauses for roughly the time it takes to stop the threads at a safepoint.
G1 keeps pause times in the tens of milliseconds by collecting in small region increments, while ZGC keeps them under a millisecond regardless of heap size by doing the compaction work concurrently with the application — the price is extra CPU and heap headroom.
The decision is not about which collector is newer.…