是-XX:+ UseG1GC正确替换-Xincgc? [英] Is -XX:+UseG1GC the correct replacement for -Xincgc?

查看:436
本文介绍了是-XX:+ UseG1GC正确替换-Xincgc?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我们正在使用增量垃圾回收器,在java命令中加入 -Xincgc 。在JDK 8中,此开关已弃用。那么等效替代品是什么? -XX:+ UseG1GC



背景:该应用程序有8GB的堆并创建了很多短暂的生活对象。我注意到它经常暂停几秒钟来做垃圾收集。出于好奇,我添加了 -Xincgc ,发现停顿不见了,整体表现提升了4倍。

不幸的是,我没有找到任何关于 -Xincgc 触发器的垃圾收集器类型的信息。有CMS(并发标记和扫描)和新的G1(垃圾优先)。但是我怎样才能得到 -Xincgc

解决方案

对于Oracle / OpenJDK 8大多数机器上的默认收集器是并行吞吐量收集器,
,除了一些32位Windows机器,它可以是串行GC。



Xincgc is CMS在增量模式下。您看到的主要好处可能是由从吞吐量收集器切换到CMS,而不是从专为单核CPU设计的增量模式引起。

a href =http://openjdk.java.net/jeps/173 =nofollow noreferrer>增量模式也被弃用,所以只需通过 -XX启用CMS:+:+ UseConcMarkSweepGC 并查看它是否适合您。



当然,您也可以尝试G1GC,它也可以达到较低的暂停时间目标,具有的优点是它不会像CMS那样遭受碎片化,因此不太可能遇到导致单线程停止世界收集的并发模式故障。



因此,请尝试并衡量。



另见: Oracle的Java 8 GC调优指南


Currently we are using the incremental garbage collector by adding -Xincgc to the java command. In JDK 8 this switch is deprecated. So what's the equivalent replacement for it? -XX:+UseG1GC?

Background: The application has a heap of 8GB and creates a lot of short living objects. I noticed that it often paused for some seconds to do garbage collection. Out of curiosity I added the -Xincgc and found that the pauses were gone and overall performance improved ~4 times.

Unfortunately I did not find any information about what type of garbage collector the -Xincgc triggers. There's the CMS (Concurrent mark and sweep) and the new G1 (Garbage first). But what do I get with -Xincgc?

解决方案

For Oracle/OpenJDK 8 the default collector on most machines is the Parallel Throughput Collector, except for some 32bit windows machines where it can be the Serial GC.

Xincgc is CMS in incremental mode. The main benefit you're seeing probably is caused by switching from the Throughput Collector to CMS, not from the incremental mode, which is designed for single-core CPUs.

Incremental Mode is also deprecated, so simply enable CMS via -XX:+UseConcMarkSweepGC and see if that works for you.

Of course you can also try G1GC, which is also designed to reach low pause time goals and has the advantage that it does not suffer from fragmentation like CMS does and thus is less likely to experience concurrent mode failures which result in a single-threaded stop the world collection.

So, try both and measure.

See also: Oracle's Java 8 GC Tuning Guides

这篇关于是-XX:+ UseG1GC正确替换-Xincgc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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