Java Core & JVM (50 Qs)•Part 3: JVM Internals, Low-Latency Systems & Production Tuning (25 - 35)
Modern Garbage Collectors: ZGC vs Shenandoah vs G1GC.
senior LevelMemory Management
In Simple Words:
- G1GC (Default): Divides heap into regional blocks. Target pause time $\le 200\text{ms}$. Balances throughput against pause times for moderate heaps (4GB - 32GB).
- ZGC (Generational ZGC in Java 21+): Low-latency collector using colored pointers and load barriers. Guarantees sub-millisecond pause times ($< 1\text{ms}$) regardless of heap size (from 16MB to 16 Terabytes!).
- Shenandoah: Ultra-low-latency collector performing concurrent compaction alongside running Java application threads.