Java / Java 17 Garbage Collection Interview Questions
Why doesn't Java 17 include the CMS garbage collector?
CMS (Concurrent Mark Sweep) was formally deprecated in JDK 9 (JEP 291) and removed entirely in JDK 14 (JEP 363), so it was already gone well before Java 17.
The main reasons were fragmentation and maintenance cost: CMS did not compact the old generation as part of its normal cycle, so long-running applications could accumulate fragmented free space and eventually be forced into an expensive fallback full GC anyway. Maintaining CMS in parallel with G1 - which is concurrent, region-based, and compacting - also added significant ongoing engineering overhead for diminishing benefit once G1 matured.
G1 was judged to cover CMS's low-pause use case just as well, without the fragmentation downside, which made removing CMS a reasonable simplification of the JVM's collector portfolio.
More Related questions...