how to solve 'java.lang.OutOfMemoryError: GC overhead limit exceeded'

依然范特西╮ 提交于 2019-12-07 16:39:16

问题


I read this stack overflow page about solving this problem and tried adding the command line option -XX:-UseGCOverheadLimit and also "-Xmx" arguments. However, my program still threw the out of memory error.

The program saves a large number (>40,000 keys) of words into a MultiKeyMap and is running on a server with plenty of memory.

Any suggestions on how I can aviod the error?


回答1:


If your problem is reliably reduced (to be honest, even if it's not) I suggest activating the -XX:+HeapDumpOnOutOfMemoryError JVM flag. This will, when there is an OutOfMemoryError, produce a binary dump of the memory. This can then be analysed by tools such as Eclipse MAT to identify potential memory leaks and help to explain why the Garbage Collector is having such a hard time clearing out your objects.




回答2:


This problem means that Garbage Collector cannot free enough memory for your application to continue. So even if you switch that particular warning off with "XX:-UseGCOverheadLimit" your application will still crash, because it consumes more memory than is available.

I would say you have memory leak symptoms. Either try digging in memory dump as suggested in another answer, or try Plumbr, which is memory leak monitoring tool created exactly for these situations.




回答3:


"GC Overhead limit" might be related to a memory leak, but it does not have to be the case. Based on the original question it is hard to say what the real problem is. You should have a "normal" Command line Config without all esotheric flags, and a sensible setting for Xmx to hold all your data. You should activate verbose gc logging to understand what GC is actually causing the overhead and tune it by changing the GC strategy or the generation sizes.

Usually the Overhead error come sup when you use structures that try to be memory friendly and use soft or weak references. If you use them on your own, double check that you understand what they do, because they can easily be misunderstood.



来源:https://stackoverflow.com/questions/12813203/how-to-solve-java-lang-outofmemoryerror-gc-overhead-limit-exceeded

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!