Java / Java 17 Garbage Collection Interview Questions
What is the default garbage collector in Java 17?
G1 (Garbage-First) GC is the default collector in Java 17, a role it has held since it replaced Parallel GC as the default in JDK 9 (JEP 248).
G1 divides the heap into many equal-sized regions rather than fixed contiguous generations, which lets it collect only the regions holding the most garbage first, aiming to meet a configurable pause-time goal (-XX:MaxGCPauseMillis, 200ms by default) while still delivering solid overall throughput.
It was chosen as the default because it works well out of the box across a wide range of heap sizes and workloads without heavy manual tuning, unlike Parallel GC (throughput-only) or the now-removed CMS (fragmentation-prone).
More Related questions...