JDK8为什么不用CMS做为默认垃圾收集器呢
1.CMS单线程或者双线程情况下效率很低
2.CMS会并发失败
3.CMS可中止的预处理会导致极限5S停顿4.并发失败进入 foregroud还会导致进入Full GC,全局MSC整理5.CMS吞吐的设计并不是很优秀
G1的目的:
GarbageFirst,也就是垃圾优先原则,也就是空间方面的关注点。同时照顾到停顿时间以及吞吐量。
Open.JDK官网:http://openjdk.java.net/jeps/307
The G1 garbage collector is designed to avoid full collections, but when the concurrent collections can't eclaim memory fast enough a fall back full GC will occur. The current implementation of the full GC for Gl uses a single threaded mark-sweep-compact algorithm. We intend to parallelize the
mark-sweep-compact algorithm and use the same number of threads as the Young and Mixed
collections do.
翻译:G1垃圾收集器的设计目的是避免完全回收,但是当并发收集不能足够快地回收内存时,就会发生完全回收GC.G1的完整GC的当前实现使用单线程mark-sweep compact算法。
.mahbin.COn
G1的特点:
gaebage First
内存空间的重新定义
更短的停顿时间要多短就多短
某种程度上去解决空间碎片