Q38: How do Garbage Collection algorithms compare (G1GC vs ZGC)?
- G1GC (Garbage-First): Default collector in Java 9+. Splits heap into region grids (~1-32MB). Targets configurable pause times (
-XX:MaxGCPauseMillis) by prioritizing regions with the most garbage. - ZGC (Z Garbage Collector): Low-latency collector (Java 15+). Scales to terabyte heaps with sub-millisecond pause times using colored pointers and load barriers during concurrent execution phases.
Key Takeaways
- G1GC = Region grid based, default enterprise collector.
- ZGC = Sub-millisecond pauses for massive multi-gigabyte/terabyte heaps.
Knowledge Check
Which Garbage Collector guarantees sub-millisecond maximum pause times even on multi-terabyte heaps?