JVM究竟是抛出一个OutOfMemoryError [英] When exactly is the JVM throwing an OutOfMemoryError

查看:91
本文介绍了JVM究竟是抛出一个OutOfMemoryError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在运行一个有时会冻结的Java应用程序,因为某些线程几乎在使用所有的堆。
尽管JVM执行的Full GC持续时间超过60秒,但应用程序永远不会因OutOfMemoryError而死亡。



我从Java文档中读到:


如果垃圾收集花费了太多时间,吞吐量收集器将抛出内存不足异常。
例如,如果JVM花费的时间超过了执行垃圾收集总时间的98%,并且正在恢复少于2%的堆,它将引发内存不足的情况。


我想知道98%的时间意味着什么(时间框架是什么?),如果可以降低这个值,即如果应用程序在GC中花费90%的时间并且无法释放超过10%的堆,则抛出OOME。



目标是确保应用程序将因为我们可以在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 \


解决方案


我想知道98%的时间意味着什么(时间框架是什么? / p>

回答此问题:超出GC开销限制表示它是1分钟。


可以降低此值


再次查看上面提到的问题,看起来您可以使用 GCTimeLimit GCHeapFreeLimit 参数。


We are running a Java application that sometimes "freezes" because some thread is using almost all the heap. Despite the JVM doing Full GC that last more than 60 seconds the application never dies with OutOfMemoryError.

I read from Java documentation that :

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.

I would like more information about what this 98% of time means (what is the time frame ?), and if it is possible to lower this value, i.e. throw an OOME if the application is spending 90% of time in GC and cannot free more than 10% of the heap.

The goal is to make sure the application will die (instead of running doing only GC) with OOME so we can generate a dump on OOME.

Here are the memory and GC settings we use (OS is 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 ?)

Answer to this question: GC overhead limit exceeded suggests it is 1 minute.

is possible to lower this value

Once again looking into the question mentioned above, looks like you can use GCTimeLimit and GCHeapFreeLimit parameters.

这篇关于JVM究竟是抛出一个OutOfMemoryError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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