NOTE
7.13 4. Selecting a Specific Garbage Collector with JVM Parameters
JVM startup options select garbage collectors. These notes record collector combinations for young and old generations and their corresponding flags.
This is a historical learning note and may contain outdated or incomplete understanding.
1. Matching the Young and Old Generations

2. JVM Parameters
-XX:+UseSerialGC
The young generation uses Serial (copying algorithm), and the old generation uses Serial Old (mark-compact).
-XX:+UseParNewGC
The young generation uses ParNew (copying algorithm), and the old generation uses Serial Old (mark-compact).
-XX:+UseParallelGC or -XX:+UseParallelOldGC
The young generation uses Parallel Scavenge (copying, focused on throughput), and the old generation uses Parallel Old (mark-compact).
-XX:+UseConcMarkSweepGC
The young generation uses ParNew (copying algorithm), and the old generation uses a combination of CMS (mark-sweep) + Serial Old fallback (mark-compact).
-XX:+UseG1GC
Overall it uses mark-compact, while locally it uses a copying algorithm.
3. How to Choose
- Single CPU or small memory, such as a standalone program
-XX:+UseSerialGC
- Multiple CPUs and maximum throughput is needed, such as backend computing applications (big-data field)
-XX:+UseParallelGC
-XX:+UseParallelOldGC
- Multiple CPUs and low pause time is needed, such as Internet applications
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC
Drag to pan, scroll to zoom, and click a node to expand or collapse it. Large maps start with deeper levels collapsed; click nodes to expand them.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub