我们在介绍了Java8的默认收集器ParallelGC后, 很多人就继续追问那Java9默认使用哪种收集器呢?
直接看官方文档(https://docs.oracle.com/javase/9/whatsnew/toc.htm#JSNEW-GUID-B6CD8C25-FD93-4CAA-9286-19A39CC0F26A),
其中一段
Makes Garbage-First (G1) the default garbage collector (GC) on 32- and 64-bit server configurations. Using a low-pause collector such as G1 provides a better overall experience, for most users, than a throughput-oriented collector such as the Parallel GC, which was previously the default.
See Garbage-First Garbage Collector in Java Platform, Standard Edition HotSpot Virtual Machine Garbage Collection Tuning Guide
Java9默认使用期待已久的G1, 同时删除了好多之前的jvm垃圾收集器组合与参数,例如ParNew + SerialOld这种组合就不存在了,CMS这样的参数-XX:+CMSFullGCsBeforeCompaction(原来的含义是执行多少次不压缩的Full GC后,跟着来一次压缩的,默认值为0, 表示每次Full GC都进行GC整理)。
关于G1收集器的详细内容,可以阅读https://docs.oracle.com/javase/9/gctuning/garbage-first-garbage-collector.htm#JSGCT-GUID-ED3AB6D3-FD9B-4447-9EDF-983ED2F7A573。
JDK的主要文档都可以在找到 https://docs.oracle.com/en/java/javase/index.html