Serial 串行收集器
# 新生代 Serial (DefNew) + 老年代 Serial Old
-XX:+UseSerialGC
小型程序。默认情况下不会是这种选项,HotSpot会根据计算及配置和JDK版本自动选择收集器
Parallel 并行收集器
# 新生代 ParallelScavenge + 老年代 ParallelOld (JDK7, JDK8 为默认垃圾回收器)
-XX:+UseParallelGC
# 新生代 ParallelScavenge + 老年代 ParallelOld, 同上
-XX:+UseParallelOldGC
# 新生代 ParallelScavenge + 老年代 SerialOld ,JDK14 开始弃用
-XX:+UseParallelGC -XX:-UseParallelOldGC
- JDK14 开始弃用 ParallelScavenge + SerialOld 组合,https://openjdk.java.net/jeps/366
ParNew + SerialOld 收集器
# 新生代 ParNew + 老年代 SerialOld
-XX:+UseParNewGC
- JDK9 : Various GC combinations have now been removed : http://bugs.java.com/view_bug.do?bug_id=JDK-8044022
The GC combinations that were deprecated in JDK 8 have now been removed. This means that the following GC combinations no longer exist: - DefNew + CMS - ParNew + SerialOld - Incremental CMS The "foreground" mode for CMS has also been removed.
CMS 收集器
# 新生代 ParNew + 老年代 CMS + 老年代 Serial Old
# 某些版本的参数是这样的: -XX:+UseConcurrentMarkSweepGC
-XX:+UseConcMarkSweepGC
- JEP 363 Remove the Concurrent Mark and Sweep (CMS) Garbage Collector: https://openjdk.java.net/jeps/363 (JDK14)
G1 收集器
# JDK 10, 11, 13 为默认垃圾回收器
-XX:+UseG1GC
ZGC 收集器
-XX:+UnlockExperimentalVMOptions -XX:+UseZGC
- https://wiki.openjdk.java.net/display/zgc
- JEP 333 ZGC A Scalable Low-Latency Garbage Collector (Experimental) : http://openjdk.java.net/jeps/333 (JDK11)
- JEP 365 ZGC on Windows : https://openjdk.java.net/jeps/365 (JDK14)
- JDK14 JEP 364 ZGC on macOS : https://openjdk.java.net/jeps/364 (JDK14)
Epsilon 收集器
-XX:+UseEpsilonGC
- JEP 318 Epsilon, A No-Op Garbage Collector : http://openjdk.java.net/jeps/318
Shenandoah 收集器
-XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC
- https://wiki.openjdk.java.net/display/shenandoah
- JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental) http://openjdk.java.net/jeps/189 (JDK12)
by Sven Augustus https://my.oschina.net/langxSpirit