Skip to content
Veltoryx Technologies
ProLesson 10.5Advanced4 min readUpdated 30 October 2026

Garbage collectors: G1, ZGC, Parallel and Serial

The main HotSpot garbage collectors, what each optimises for, how to choose, and the JVM options you'll actually use.

The JVM ships with several garbage collectors. Each makes a different trade-off between throughput (how much CPU time goes to your code rather than GC), latency (how long pauses are) and memory footprint.

01The collectors at a glance

CollectorFlagOptimised forPausesTypical use
Serial-XX:+UseSerialGCTiny footprintStop-the-world, single threadSmall heaps, small containers, CLI tools
Parallel-XX:+UseParallelGCMaximum throughputStop-the-world, many threadsBatch jobs where pauses don't matter
G1 (default)-XX:+UseG1GCA balance of throughput and predictable pausesShort, with a target pause timeMost server applications
ZGC-XX:+UseZGCVery low latencyTypically under a millisecond, mostly concurrentLarge heaps, latency-sensitive services
Shenandoah-XX:+UseShenandoahGCLow latencyMostly concurrentAvailable in many OpenJDK builds

G1 has been the default since Java 9, on machines the JVM considers "server class". On very small machines (one CPU or little memory) the JVM may pick Serial instead.

Loading the rest of the lesson…