gpt4 book ai didi

java - -XX :+UseParallelGC and -XX:+UseParNewGC 的区别

转载 作者:IT老高 更新时间:2023-10-28 11:44:38 31 4
gpt4 key购买 nike

它们是年轻代垃圾收集的算法。

第二个 (UseParNewGC) 通过并发的终身代垃圾收集自动激活(请参阅 Java Concurrent and Parallel GC )但是,这两种并行算法之间有区别吗?

最佳答案

经过大量搜索,我发现最好的解释来自 Java Performance Tuning website in Question of the month: 1.4.1 Garbage collection algorithms, January 29th, 2003

Young generation garbage collection algorithms

The (original) copying collector (Enabled by default). When this collector kicks in, all application threads are stopped, and the copying collection proceeds using one thread (which means only one CPU even if on a multi-CPU machine). This is known as a stop-the-world collection, because basically the JVM pauses everything else until the collection is completed.

The parallel copying collector (Enabled using -XX:+UseParNewGC). Like the original copying collector, this is a stop-the-world collector. However this collector parallelizes the copying collection over multiple threads, which is more efficient than the original single-thread copying collector for multi-CPU machines (though not for single-CPU machines). This algorithm potentially speeds up young generation collection by a factor equal to the number of CPUs available, when compared to the original singly-threaded copying collector.

The parallel scavenge collector (Enabled using -XX:UseParallelGC). This is like the previous parallel copying collector, but the algorithm is tuned for gigabyte heaps (over 10GB) on multi-CPU machines. This collection algorithm is designed to maximize throughput while minimizing pauses. It has an optional adaptive tuning policy which will automatically resize heap spaces. If you use this collector, you can only use the the original mark-sweep collector in the old generation (i.e. the newer old generation concurrent collector cannot work with this young generation collector).

从这些信息看来,主要区别(除了 CMS 合作)是 UseParallelGC 支持 ergonomics 而 UseParNewGC 没有。

关于java - -XX :+UseParallelGC and -XX:+UseParNewGC 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2101518/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com