简体   繁体   English

Tomcat上垃圾收集器的奇怪行为

[英]Strange Behaviour of Garbage Collector on Tomcat

we have a really strange behaviour with one of our apps running on a Tomcat 7 (with Java 1.6) 我们的其中一个应用程序在Tomcat 7(带有Java 1.6)上运行时,我们的行为确实很奇怪

The app runs really good for some days, then we see a peak in the Garbage Collector Time, the CPU Usage is more than 10 times of he normal load and the memory isn't freed anymore: 该应用程序运行了好几天,然后我们看到垃圾收集器时间达到峰值,CPU使用率是正常负载的10倍以上,并且内存不再释放:

已用记忆体

The last drop was a restart of the app so the performance gets better. 最后一滴是重新启动应用程序,因此性能得到了提高。 as you can see in the graph the space which is freed by the GC gets lower and lower at each run and at the end it isn't going to free any memory, so the performance of the app goes really low. 从图中可以看到,GC释放的空间在每次运行时都越来越小,最终它不会释放任何内存,因此该应用程序的性能确实降低了。

how can this behaviour be improved? 如何改善这种行为?

This looks like a memory leak - if the GC can't free the memory any more, it is most probably due to some code retaining references to unused objects. 这看起来像是内存泄漏-如果GC无法再释放内存,则很可能是由于某些代码保留了对未使用对象的引用。 You should try to track the objects remaining in memory (that graphic tool of yours should have some way to peek into the heap memory regions and give you information on created objects) and make sure you erase any reference to unused objects so the GC can free them. 您应该尝试跟踪保留在内存中的对象(您的图形工具应该有某种方式可以窥探堆内存区域并为您提供有关已创建对象的信息),并确保您删除对未使用对象的任何引用,以便GC可以释放他们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM