如何配置GC以阻止世界? [英] How to configure GC to not stop the world?

查看:142
本文介绍了如何配置GC以阻止世界?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个 JVM 1.7,它通常以1G max运行。堆大小。并且仅使用〜0.5G的堆。

在某些时候,堆使用在几分钟内急剧增加(我怀疑负载增加而不是内存泄漏)和GC( PS MarkSweep )开始。 GC运行了大约30分钟,服务器一直没有响应。



堆统计数据显示,在那一刻旧Gen 堆用量增加, Eden 减少,并且 max Survivor 也增加了。
$ b JVM使用默认选项 -XX:+ UseParallelGC



我会尝试增加堆,限制输入数据大小等等。但是我想知道如何调整GC来 not 停止世界半个小时。我不介意服务器是否放慢速度,但我不希望它停止响应。



如何配置GC以阻止世界 / em>?

解决方案

虽然你不能保证(除非你像Zing一样在VM上),你可以给软目标它将尝试实现的GC。在这里看到更多。
Oracle Technetwork。 PT。人体工程学


XX:MaxGCPauseMillis = 。这被解释为暂停时间为毫秒或更少; ...请注意,这些调整可能会导致垃圾收集器降低应用程序的整体吞吐量,并且在某些情况下无法满足所需的暂停时间目标。



-XX:GCTimeRatio = 。吞吐量目标是根据进行垃圾回收的时间与垃圾回收以外的时间(称为应用程序时间)来衡量的。目标由命令行选项-XX:GCTimeRatio =指定,该选项将垃圾收集时间与应用程序时间的比率设置为1 /(1 +)。例如,-XX:GCTimeRatio = 19可设置垃圾收集总时间的1/20或5%。默认值为99,导致垃圾收集时间的目标为1%。


PS。不过,我认为,如果一个应用程序在GC中花费30分钟时间,那么应用程序出现问题的可能性会更大,除非您尝试在某个传统平台上运行该应用程序,否则不会与GC本身有关。

Suppose I have a JVM 1.7, which runs normally with 1G max. heap size. and uses only ~0.5G of heap.

At some moment the heap usage steeply increased in few minutes (I suspect increased load not a memory leak) and GC (PS MarkSweep) started. The GC was running for about 30 min. and the server did not respond all that time.

The heap stats shows that at that moment Old Gen heap usage increased, Eden decreased, and max Survivor increased too.

The JVM uses default option -XX:+UseParallelGC

I will try to increase the heap, limit the input data size, etc. However I wonder how I can tune the GC to not "stop the world" for half an hour. I don't mind if the server slows down but I do not want it to stop responding at all.

How to configure GC to not stop the world ?

解决方案

While you can't have guarantees (unless you are on VM like Zing) you can give soft goals to GC which it will try to achieve. See more here. Oracle Technetwork. pt. Ergonomics

XX:MaxGCPauseMillis=.This is interpreted as a hint that pause times of milliseconds or less are desired; ... Note that these adjustments may cause the garbage collector to reduce the overall throughput of the application and in some cases the desired pause time goal cannot be met.

-XX:GCTimeRatio=.The throughput goal is measured in terms of the time spent doing garbage collection vs. the time spent outside of garbage collection (referred to as application time). The goal is specified by the command line option -XX:GCTimeRatio=, which sets the ratio of garbage collection time to application time to 1 / (1 + ). For example, -XX:GCTimeRatio=19 sets a goal of 1/20 or 5% of the total time in garbage collection. The default value is 99, resulting in a goal of 1% of the time in garbage collection.

PS. However, I have an opinion that if an app with 0.5Gb heap spends 30 minutes in GC there are more chances that there's something wrong with the app, not with GC itself unless you are trying to run the app on some legacy platform.

这篇关于如何配置GC以阻止世界?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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