English
GC Algorithms at a Glance
A quick field guide to the collectors EasyGC recognizes, and when to pick which.
The collectors
| Collector | Flag | Strategy | Typical pause | Good for |
|---|---|---|---|---|
| Serial | -XX:+UseSerialGC | Single-threaded, generational | 100 ms – seconds | Small heaps, single-core containers, batch tools |
| Parallel | -XX:+UseParallelGC | Multi-threaded, generational | 50 ms – seconds | Max throughput, batch/analytics, latency-tolerant |
| CMS | -XX:+UseConcMarkSweepGC | Mostly concurrent old-gen | 10 – 100 ms | Legacy low-latency services (removed in Java 14) |
| G1 | -XX:+UseG1GC | Region-based, concurrent marking | 10 – 200 ms (targeted) | Default since Java 9; balanced throughput/latency |
| ZGC | -XX:+UseZGC | Concurrent, colored pointers | < 1 ms | Huge heaps, strict SLOs (Java 15+) |
| Shenandoah | -XX:+UseShenandoahGC | Concurrent, forwarding pointers | < 10 ms | Low latency on OpenJDK builds |
How to choose
- Default choice: G1. It is the JDK default for a reason — predictable pauses with decent throughput.
- Throughput above all (batch jobs, data pipelines)? Parallel GC gives the best raw throughput at the cost of longer pauses.
- Strict latency SLO (p99 < 50 ms) with a large heap? ZGC or Shenandoah keep pauses in the sub-10 ms range regardless of heap size.
- Tiny container (≤ 512 MB)? Serial GC often beats everything — no threads to coordinate.
Key tuning knobs
| Knob | Meaning |
|---|---|
-Xms / -Xmx | Initial / maximum heap size. Setting them equal avoids resize pauses. |
-Xmn / -XX:NewRatio | Young generation size — the main lever on GC frequency. |
-XX:MaxGCPauseMillis | G1 pause goal (default 200 ms). Don't set it unrealistically low. |
-XX:MaxMetaspaceSize | Cap for class metadata — prevents metaspace-driven Full GCs. |
-XX:+DisableExplicitGC | Ignore System.gc() calls (check Direct ByteBuffers first!). |
-XX:G1HeapRegionSize | G1 region size — raise it if humongous allocations dominate. |
Reading the signals in your report
Allocation Failureyoung GCs are normal and healthy.System.gc()causes are almost always worth removing.Metadata GC Threshold/ Metaspace causes point at classloader churn.G1 Humongous Allocationmeans objects larger than half a region — refactor or enlarge regions.- A steadily climbing after-GC heap means leaked objects survived collection — see Understanding the Report.