NOTE

Selecting a JVM Garbage Collector

Collector-selection principles and JVM flags, with emphasis on verifying support against the deployed JDK instead of copying obsolete flag recipes.

JavaCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. Start from the Goal

Do not choose a collector from a fixed cheat sheet. Decide whether the dominant goal is throughput, tail latency, small-memory simplicity, or very large-heap pause control.

2. Collector Flags

HotSpot collector-selection flags have historically included options such as -XX:+UseG1GC, -XX:+UseParallelGC, -XX:+UseSerialGC, -XX:+UseZGC, and collector-specific alternatives.

Exact availability, defaults, and tuning flags depend on the deployed JDK build/version. Verify with that runtime’s documentation and java -XX:+PrintFlagsFinal/supported diagnostics rather than assuming an old list remains valid.

3. Avoid Premature Knob Tuning

First set sensible memory/container limits and observe allocation rate, live set, pause distribution, and CPU. Modern collectors are designed to self-tune many internal details.

Tune only when measurements show a concrete problem and verify the result under representative load.

Loading helpful count