NOTE
JVM Garbage Collectors
A durable overview of Serial, Parallel, G1, ZGC, Shenandoah-style collector goals without treating historical defaults as permanent facts.
This is a historical learning note and may contain outdated or incomplete understanding.
1. Collector Families
HotSpot has offered multiple collectors because different applications optimize for different goals.
- Serial: simple, mostly single-threaded collection; useful for small heaps/simple environments.
- Parallel: emphasizes throughput with parallel GC work and stop-the-world phases.
- G1: region-based collector designed to balance throughput with pause-time goals.
- ZGC and Shenandoah-style designs: move more GC work concurrently to target very low pause times, at additional CPU/memory/implementation cost.
2. Historical Collectors
CMS and older combinations are important historically but should not be taught as the default modern choice. Collector availability/defaults change across JDK releases.
3. No Universal Winner
Choose based on:
- latency SLO;
- heap/live-set size;
- allocation rate;
- CPU budget;
- container/resource limits;
- operational simplicity.
4. Measure the Workload
Use GC logs, JFR, heap metrics, allocation profiling, and pause distributions. A collector name alone does not diagnose excessive allocation, memory retention, or undersized resource limits.