-XX:+ UseParallelGC和-XX:+ UseParNewGC之间的区别 [英] Difference between -XX:+UseParallelGC and -XX:+UseParNewGC

查看:71
本文介绍了-XX:+ UseParallelGC和-XX:+ UseParNewGC之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它们是用于年轻一代垃圾收集的算法.

They are algorithms for the young generation garbage collection.

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

The second one (UseParNewGC) gets activated automatically with the concurrent tenured generation garbage collection (see Java Concurrent and Parallel GC) but, is there a difference between the two parallel algorithms?

推荐答案

经过大量搜索,我发现的最佳解释是来自Java Performance Tuning网站的

After a lot of searching, the best explanation I've found is from Java Performance Tuning website in Question of the month: 1.4.1 Garbage collection algorithms, January 29th, 2003

年轻一代垃圾收集算法

(原始)复制收集器(默认情况下启用).启动此收集器后,所有应用程序线程都将停止,并且复制收集将使用一个线程继续进行(即使在多CPU机器上,这也意味着只有一个CPU).这被称为世界停止收集,因为基本上JVM会暂停其他所有操作,直到收集完成为止.

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.

并行复制收集器(使用-XX:+ UseParNewGC启用).像原始的复制收集器一样,这是一个世界末日的收集器.但是,此收集器可并行化多个线程上的复制收集,这比多CPU机器(尽管不是单CPU机器)的原始单线程复制收集器效率更高.与原始的单线程复制收集器相比,该算法有可能将年轻一代的收集速度提高一个等于可用CPU数量的倍数.

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.

并行清理收集器(使用-XX:UseParallelGC启用).这类似于以前的并行复制收集器,但是针对多CPU机器上的千兆字节堆(超过10GB)调整了算法.该收集算法旨在最大程度地提高吞吐量,同时最大程度地减少暂停时间.它具有可选的自适应调整策略,该策略将自动调整堆空间的大小.如果使用此收集器,则只能使用旧版本中的原始标记扫描收集器(即,较新的旧版本并发收集器无法与此年轻的收集器一起使用).

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支持

From this information, it seems the main difference (apart from CMS cooperation) is that UseParallelGC supports ergonomics while UseParNewGC doesn't.

这篇关于-XX:+ UseParallelGC和-XX:+ UseParNewGC之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆