java - JVM 到底什么时候抛出 OutOfMemoryError

标签 java garbage-collection out-of-memory

我们正在运行一个有时会“卡住”的 Java 应用程序,因为某些线程几乎使用了所有堆。 尽管 JVM 执行的 Full GC 持续时间超过 60 秒,但应用程序从未因 OutOfMemoryError 而死。

我从 Java 文档中读到:

The throughput collector will throw an out-of-memory exception if too much time is being spent doing garbage collection. For example, if the JVM is spending more than 98% of the total time doing garbage collection and is recovering less than 2% of the heap, it will throw an out-of-memory expection.

我想了解更多关于这 98% 的时间意味着什么的信息(时间范围是什么?),以及是否可以降低此值,即如果应用程序将 90% 的时间花在 GC 上,则抛出 OOME并且不能释放超过 10% 的堆。

目标是确保应用程序在 OOME 时死掉(而不是只运行 GC),这样我们就可以在 OOME 上生成转储。

以下是我们使用的内存和 GC 设置(操作系统是 Solaris):

-Xms2048m -Xmx2048m \
-Xmn512m \
-XX:PermSize=256m 
-XX:MaxPermSize=256m \
-XX:+UseParNewGC 
-XX:ParallelGCThreads=16 \
-XX:+UseConcMarkSweepGC 
-XX:+CMSParallelRemarkEnabled \
-XX:+DisableExplicitGC \
-XX:+PrintGC 
-XX:+PrintGCDetails 
-XX:+PrintGCTimeStamps \
-XX:+PrintClassHistogram \
-Xloggc:/gcmonitor.log \
-XX:+HandlePromotionFailure \
-XX:SurvivorRatio=4 
-XX:TargetSurvivorRatio=90 
-XX:MaxTenuringThreshold=10 \
-XX:+UseTLAB 
-XX:TLABSize=32k 
-XX:+ResizeTLAB \
-XX:+UseMPSS \

最佳答案

I would like more information about what this 98% of time means (what is the time frame ?)

这个问题的答案:GC overhead limit exceeded建议是 1 分钟。

is possible to lower this value

再次查看上述问题,看起来您可以使用 GCTimeLimitGCHeapFreeLimit 参数。

关于java - JVM 到底什么时候抛出 OutOfMemoryError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8913902/

相关文章:

c# - 如果永远不会使用引用,持有对对象的引用是否会将其保留在内存中?

Java - 因内存不足错误而关闭

android - 为什么 ASUS Transformer Prime 是唯一出现内存不足异常的设备

c# - Crystal Reports ActiveX Viewer 在 VB6/.NET App Windows 7 中导致内存不足异常

java - Axis2 stub 生成问题

garbage-collection - Node.js 和 V8 垃圾回收

Java-Selenium 允许弹出窗口

java - 垃圾收集最小化。有人会澄清一些关于迭代器的事情吗?

java - 从 TreeMap 克隆对象中删除元素不会从 java 中的主树形图对象中删除

Java:双数据类型值没有给出确切的答案