Garbage collection
Choosing a collector, tuning G1 and reading the unified GC log without guesswork.
- Choosing a HotSpot garbage collector: Serial, Parallel, G1, ZGC or Shenandoah
What each HotSpot collector optimises for, which one the JVM picks by default and why, the flags that select them, and a practical way to decide based on latency, throughput and footprint.
- Reading GC logs with -Xlog:gc: unified logging from setup to diagnosis
How to enable the JDK's unified GC logging with rotation and useful decorators, how the old PrintGC flags map to -Xlog, how to read G1 pause lines, and which patterns point to an undersized heap, a leak or a pause problem.
- Running generational ZGC in production: heap headroom, SoftMaxHeapSize and allocation stalls
How generational ZGC differs from the original ZGC, which JDK release enables what, why the maximum heap size is the main tuning knob, how SoftMaxHeapSize, uncommit and large pages behave, and how to recognise and fix allocation stalls in the GC log and in JFR.
- Tuning G1 in production: the few options that matter
How G1 organises the heap into regions and meets a pause-time target, which flags are worth changing (heap size, MaxGCPauseMillis, IHOP, region size), which ones to leave alone, and how to recognise humongous allocations and evacuation failures.



