假设我有一个 JVM
1.7,它可以正常运行,最大内存为 1G。堆大小。并且仅使用约 0.5G 的堆。
在某些时刻,堆使用量在几分钟内急剧增加(我怀疑负载增加不是内存泄漏)并且 GC (PS MarkSweep
) 开始。 GC 运行了大约 30 分钟,并且服务器一直没有响应。
堆统计数据显示,此时 Old Gen
堆使用量增加,Eden
减少,max Survivor
也增加了。
JVM使用默认选项-XX:+UseParallelGC
我会尝试增加堆、限制输入数据大小等。但是我想知道如何调整 GC,使其不“停止世界”半小时。我不介意服务器是否变慢,但我不希望它完全停止响应。
如何配置 GC 才不会停止世界?
最佳答案
虽然您无法做出保证(除非您使用像 Zing 这样的 VM),但您可以为 GC 提供软目标,GC 将尝试实现该目标。在这里查看更多。 Oracle Technetwork. pt. Ergonomics
PS。但是,我认为,如果具有 0.5Gb 堆的应用程序在 GC 中花费 30 分钟,则更有可能该应用程序出现问题,而不是 GC 本身出现问题,除非您尝试在某些旧平台上运行该应用程序。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.
关于java - 如何配置GC不让世界停止?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29577993/