NOTE

7.13 4. Selecting a Specific Garbage Collector with JVM Parameters

Matching young- and old-generation collectors, JVM parameters, and how to choose.

JavaCreated Updated 1 min readhistorical

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

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub