OpenJDK 27版本的垃圾回收子组件迎来了重要升级,共计约350项变更[1]。其中最为关键的改动是通过JEP 523将G1垃圾回收器设定为所有环境的默认收集器,正式取代了之前的Serial GC[1]。用户如需继续使用Serial GC,可通过-XX:+UseSerialGC选项手动指定[1]。
本次更新涵盖了多个垃圾回收器的优化与修复。在G1 GC方面,MinHeapFreeRatio和MaxHeapFreeRatio的默认值分别调整为0和100,相比之前的40和70有所改变[1]。Parallel GC引入了自适应保有期阈值的降低机制(JDK-8380590),改进了堆大小的动态调整能力[1]。此外,针对创建大量短生命周期线程的应用场景,团队对TLAB(线程本地分配缓冲)大小调整进行了优化(JDK-8381834)[1]。
从变更构成来看,约50%的改动为代码重构和清理工作,35%属于bug修复,余下15%涉及新功能或行为改进[1]。
OpenJDK 27 has rolled out approximately 350 changes to its garbage collection subsystem, with the most significant being the elevation of the G1 garbage collector to default status across all deployment scenarios [1]. This shift, implemented through JEP 523, replaces the previous reliance on Serial GC and marks a substantial evolution in the Java platform's memory management strategy [1]. Users who require Serial GC functionality can still access it manually via the -XX:+UseSerialGC option [1].
Beyond the default collector change, the release encompasses multiple refinements to G1, Parallel, and Serial garbage collectors. The G1 GC now adjusts its minimum and maximum heap free ratio defaults from 40 and 70 percent to 0 and 100 percent, respectively, improving heap size adaptability [1]. The Parallel GC has gained enhanced capability to lower its adaptive tenure threshold, addressing more flexible heap resizing requirements [1]. Additionally, Thread Local Allocation Buffer (TLAB) sizing has been refined to better serve applications that create large numbers of short-lived threads [1].
The composition of these updates reflects a balanced approach to platform maturation: roughly 50 percent of all changes involve code refactoring and cleanup, approximately 35 percent address bug fixes, while the remaining 15 percent introduce new features or behavioral improvements [1].