gpt4 book ai didi

Java垃圾回收微调: Maximum pause time goal

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:56:44 26 4
gpt4 key购买 nike

来自甲骨文 documentaiton

最长停顿时间目标

The pause time is the duration during which the garbage collector stops the application and recovers space that is no longer in use. The intent of the maximum pause time goal is to limit the longest of these pauses. An average time for pauses and a variance on that average is maintained by the garbage collector. The average is taken from the start of the execution but is weighted so that more recent pauses count more heavily.

If the average plus the variance of the pause times is greater than the maximum pause time goal, then the garbage collector considers that the goal is not being met.

The garbage collector will adjust the Java heap size and other parameters related to garbage collection in an attempt to keep garbage collection pauses shorter than milliseconds. By default there is no maximum pause time goal. These adjustments may cause garbage collector to occur more frequently, reducing the overall throughput of the application. The garbage collector tries to meet any pause time goal before the throughput goal. In some cases, though, the desired pause time goal cannot be met.

对于 CMS 算法,GC 时间过长和 OutOfMemoryError。

如果未达到最大暂停时间目标会怎样?它是否忽略违规并继续,因为它就像目标已经实现一样?或者抛出一些异常,比如 CMS 抛出 OutOfMemory?

最佳答案

在 Java 8 中 GC Ergonomic文档,它说:

"This is interpreted as a hint to the garbage collector that pause times of milliseconds or less are desired."

目标只是提示,不是硬性要求。

如果 GC 不能达到目标,它就会继续。作为the same document说:

"It is typical that the size of the heap will oscillate as the garbage collector tries to satisfy competing goals. This is true even if the application has reached a steady state. The pressure to achieve a throughput goal (which may require a larger heap) competes with the goals for a maximum pause time and a minimum footprint (which both may require a small heap)."

这符合我的经验。我从未听说过 OOME 或类似消息说错误是由于未达到此目标造成的。

(但某些其他事情是硬性要求;例如最大堆大小和过多的 GC 时间限制。如果违反这些限制导致 OOME。)

关于Java垃圾回收微调: Maximum pause time goal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33803788/

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