Tomcat java.lang.OutOfMemoryError:超出了GC开销限制(Tomcat java.lang.OutOfMemoryError: GC overhead limit exc

编程入门 行业动态 更新时间:2024-10-19 06:22:58
Tomcat java.lang.OutOfMemoryError:超出了GC开销限制(Tomcat java.lang.OutOfMemoryError: GC overhead limit exceeded)

我们尝试将我们的应用程序从OC4J迁移到Tomcat 7.0。 该应用程序适用于OC4J,但在tomcat中,当运行10个用户的负载测试时,性能会受到影响。 我们得到这些错误,应用程序不再响应。

---java.lang.OutOfMemoryError: GC overhead limit exceeded Exception in thread "ajp-bio-8009-exec-231" java.lang.OutOfMemoryError: GC overhead limit exceeded Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" java.lang.OutOfMemoryError: GC overhead limit exceeded Exception in thread "ajp-bio-8009-exec-236" java.lang.OutOfMemoryError: GC overhead limit exceeded Exception in thread "ajp-bio-8009-exec-208" java.lang.OutOfMemoryError: GC overhead limit exceeded java.lang.OutOfMemoryError: GC overhead limit exceeded java.lang.OutOfMemoryError: GC overhead limit exceeded Exception in thread "Thread-33" java.lang.OutOfMemoryError: GC overhead limit exceeded Exception in thread "ajp-bio-8009-exec-258" java.lang.OutOfMemoryError: GC overhead limit exceeded java.lang.OutOfMemoryError: GC overhead limit exceeded

垃圾收集日志

GC调用= 593(完整539):PSYoungGen总计701120K,使用374720K [0x00000007aaab0000,0x00000007eaf60000,0x0000000800000000] eden space 374720K,100%使用[0x00000007aaab0000,0x00000007c18a0000,0x00000007c18a0000]来自空间326400K,0%使用[0x00000007d70a0000,0x00000007d70a0000,0x00000007eaf60000)到空间339328K,0%使用[0x00000007c18a0000,0x00000007c18a0000,0x00000007d6400000] ParOldGen总计2796224K,使用2796223K [0x0000000700000000,0x00000007aaab0000,0x00000007aaab0000]对象空间2796224K,99%使用[0x0000000700000000,0x00000007aaaaffe8,0x00000007aaab0000] PSPermGen总计50688K,使用50628K [0x00000006fae00000, 0x00000006fdf80000,0x0000000700000000)对象空间50688K,99%使用[0x00000006fae00000,0x00000006fdf713a8,0x00000006fdf80000] 4482.450:[Full GC [PSYoungGen:374720K-> 339611K(701120K)] [ParOldGen:2796223K-> 2796222K(2796224K)] 3170943K-> 3135834K( 3497344K)[PSPermGen:50628K-> 50628K(50688K)],1.4852620 secs]

We trying to migrate our application to Tomcat 7.0 from OC4J. The application works fine with OC4J but, in tomcat the performance gets affected when running load testing with 10 users. We get these errors and the application doesnt respond anymore.

---java.lang.OutOfMemoryError: GC overhead limit exceeded Exception in thread "ajp-bio-8009-exec-231" java.lang.OutOfMemoryError: GC overhead limit exceeded Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" java.lang.OutOfMemoryError: GC overhead limit exceeded Exception in thread "ajp-bio-8009-exec-236" java.lang.OutOfMemoryError: GC overhead limit exceeded Exception in thread "ajp-bio-8009-exec-208" java.lang.OutOfMemoryError: GC overhead limit exceeded java.lang.OutOfMemoryError: GC overhead limit exceeded java.lang.OutOfMemoryError: GC overhead limit exceeded Exception in thread "Thread-33" java.lang.OutOfMemoryError: GC overhead limit exceeded Exception in thread "ajp-bio-8009-exec-258" java.lang.OutOfMemoryError: GC overhead limit exceeded java.lang.OutOfMemoryError: GC overhead limit exceeded

Garbage collection logs

GC invocations=593 (full 539): PSYoungGen total 701120K, used 374720K [0x00000007aaab0000, 0x00000007eaf60000, 0x0000000800000000) eden space 374720K, 100% used [0x00000007aaab0000,0x00000007c18a0000,0x00000007c18a0000) from space 326400K, 0% used [0x00000007d70a0000,0x00000007d70a0000,0x00000007eaf60000) to space 339328K, 0% used [0x00000007c18a0000,0x00000007c18a0000,0x00000007d6400000) ParOldGen total 2796224K, used 2796223K [0x0000000700000000, 0x00000007aaab0000, 0x00000007aaab0000) object space 2796224K, 99% used [0x0000000700000000,0x00000007aaaaffe8,0x00000007aaab0000) PSPermGen total 50688K, used 50628K [0x00000006fae00000, 0x00000006fdf80000, 0x0000000700000000) object space 50688K, 99% used [0x00000006fae00000,0x00000006fdf713a8,0x00000006fdf80000) 4482.450: [Full GC [PSYoungGen: 374720K->339611K(701120K)] [ParOldGen: 2796223K->2796222K(2796224K)] 3170943K->3135834K(3497344K) [PSPermGen: 50628K->50628K(50688K)], 1.4852620 secs]

最满意答案

GC Overrhead Limit exceeded通常意味着应用程序在某些地方'泄漏'内存。 您的堆内存使用率很高,如98/99%,完整的GC可能会检索一两个百分点。 它将做的是它将花费大部分时间GCing。 JVM检查它是否经常使用GCing,如果它超过某个限制,则会抛出此错误。

要解决此问题,您需要检查泄漏发生的位置。 通过获取堆转储来执行此操作。 您可以使用jmap。 一旦你得到它,你应该看到堆的百分比可能主要属于一组对象

我们尝试了JAVA_OPTS =“ - Xms4096m -Xmx8192m。看起来我们仍然得到错误。请建议我们可以尝试的可能选项..

这是很多,只会延迟不可避免的。


从您的编辑更新

正如我所料,您的OldGen空间为99%,几乎没有回收。 OldGen空间是放置所有长寿命对象的地方。 由于您没有回收某些内存,所有这些对象最终将被放入OldGen中,并且您将耗尽内存。

值得一读的是这两条线:

ParOldGen total 2796224K, used 2796223K [0x0000000700000000, 0x00000007aaab0000, 0x00000007aaab0000) object space 2796224K, 99% Full GC [PSYoungGen: 374720K->339611K(701120K)] [ParOldGen: 2796223K->2796222K(2796224K)] 3170943K->3135834K(3497344K)

就像我提到的那样,OldGen为99%而Full GC仅回收1KB YounGen35KB OldGen 。 它将几乎立即再次GC。 此时应该是GCing GB。

所以

获取堆转储并找出这里最伟大的罪犯是什么。 调查这些对象的创建位置以及它们无法到达的原因。

如果您对如何/在何处或为何让我知道有任何其他问题,但此时我无法告诉您。

GC Overrhead Limit exceeded usually implies the application is 'leaking' memory some where. Your heap is high in memory use, like 98/99% and a full GC will retrieve maybe a percent or two. What that will do is it will spend most of the time GCing. The JVM checks to see how often it has spent GCing and if it exceeds some limit this error is what is thrown.

To resolve it you will need to check where the leak is occurring. Do this by getting a heap dump. You can use jmap for that. Once you get it, you should see the % of the heap will probably belong mostly to one set of objects

We tried JAVA_OPTS="-Xms4096m -Xmx8192m. Looks like we still get the error. Please suggest the possible options that we could try..

That's a lot and only delays the inevitable.


Edit from you update

As I expected your OldGen space is at 99% with little reclaimed. OldGen space is where all long lived object will be placed. Since you are not reclaiming some memory all of those objects will eventually be placed into OldGen and you will run out of memory.

What's worth reading are the two lines here:

ParOldGen total 2796224K, used 2796223K [0x0000000700000000, 0x00000007aaab0000, 0x00000007aaab0000) object space 2796224K, 99% Full GC [PSYoungGen: 374720K->339611K(701120K)] [ParOldGen: 2796223K->2796222K(2796224K)] 3170943K->3135834K(3497344K)

Like I mentioned, OldGen is at 99% and a Full GC only reclaims 1KB YounGen and 35KB OldGen. It will have to GC almost immediately again. It should be GCing GBs at this point.

So

Get a heap dump and find out what the greatest offender here is. Investigate where these objects are being created and why they are not becoming unreachable.

If you have any other questions about how/where or why let me know, but there is nothing else I can tell you at this point.

更多推荐

本文发布于:2023-04-29 10:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1336343.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:开销   超出了   lang   OutOfMemoryError   java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!