GC overhead limit exceeded

错误:java.lang.OutOfMemoryError: GC overhead limit exceeded

What is causing it?

The java.lang.OutOfMemoryError: GC overhead limit exceeded error is the JVM’s way of signalling that your application spends too much time doing garbage collection with too little result. By default the JVM is configured to throw this error if it spends more than 98% of the total time doing GC and when after the GC only less than 2% of the heap is recovered。

也就是说GC试图回收内存,但是什么也没有回收到。默认情况下,JVM花费了98%的时间在GC上,但是GC过之后只有不到2%的堆内存被回收。

What would happen if this GC overhead limit would not exist?

Note that the java.lang.OutOfMemoryError: GC overhead limit exceeded error is only thrown when 2% of the memory is freed after several GC cycles. This means that the small amount of heap the GC is able to clean will likely be quickly filled again, forcing the GC to restart the cleaning process again. This forms a vicious cycle where the CPU is 100% busy with GC and no actual work can be done. End users of the application face extreme slowdowns – operations which normally complete in milliseconds take minutes to finish。

So the “java.lang.OutOfMemoryError: GC overhead limit exceeded” message is a pretty nice example of a fail fast principle in action。

简单来讲,就是一次GC过后,并没有回收到内存,很快又会进行GC,极端情况下会循环GC(关键是并没有回收到可用内存),从而导致CPU 100%负载。


PS:参见 https://plumbr.eu/outofmemoryerror/gc-overhead-limit-exceeded

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容