本文介绍了Java - Full GC(垃圾收集器)在很短的时间间隔内发生,导致性能下降的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的产品环境中,我看到一些异常行为,导致运行Tomcat的服务器上的线程数很高。 10,092,544K的堆大小在新一代和任职期间分为2,752,512K + 7,340,032K = 10,092,544K。

我对GC为什么运行多重(全新GC和旧版本)(全部GC [PSYoungGen:0K-> 0K(2752512K)] [ParOldGen:2748534K-> 2748529K(7340032K)])



正如你可以看到0K-> 0K对于年轻的gen,而.27G - > .27G对于旧gen意味着几乎没有任何对象正在获得gc'd,并且有太多可用的内存。 (堆大小为10G)。



由于Full GC在很短的时间间隔内运行多次,导致性能下降,因此应用程序无法处理传入的用户请求,因此服务器上的线程很高,最终我们必须重新启动服务器才能解决这种情况。



您能解释一下这里发生了什么。



以下是gc.log的输出。









more ......

预先致谢。

解决方案

你有没有看过你的gc统计数据?

 <$ c $ (全氟化碳[PSYoungGen:0K-> 0K(2752512K)] [ParOldGen:2748534K-> 2748529K(7340032K)] 2748534K-> 2748529K(10092544K)[PSPermGen:262143K-> 262143K(262144K)], 3.0554520秒] 

重要的部分是[PSPermGen:262143K-> 262143K(262144K)] 即可。您 PermGenSpace 已用完,因此完成了一次GC。因此,为了解决这个问题,可以进一步增加 PermGenSpace (可能通过减少你的堆空间)。

不要在不重新启动Tomcat的情况下将其部署到生产系统上,因为这会耗尽您的 PermGenSpace 非常快。


I am seeing some abnormal behavior in our prod environment that is causing us high thread count on server that is running Tomcat. The heap size of 10,092,544K is divided between new generation and tenure generation as 2,752,512K + 7,340,032K = 10,092,544K.

I am confused as to why GC is running itself multiple times when there is enough memory available on heap (new and old gen both) (Full GC [PSYoungGen: 0K->0K(2752512K)] [ParOldGen: 2748534K->2748529K(7340032K)] )

As you can see 0K->0K for young gen and .27G -> .27G for old gen means hardly any objects are getting gc'd and there is so much of memory available. (heap size is 10G).

Since Full GC is running multiple times during short interval, it is causing slow performance and hence application can't handle the incoming user requests and hence high threads on server and eventually we have to restart server to come out of this situation.

Can you please explain what is happening here.

Here is output on gc.log.


..

more........

Thanks in advance.

解决方案

Have you looked at your gc stats?

[Full GC [PSYoungGen: 0K->0K(2752512K)] [ParOldGen: 2748534K->2748529K(7340032K)] 2748534K->2748529K(10092544K) [PSPermGen: 262143K->262143K(262144K)], 3.0554520 secs]

The important part is [PSPermGen: 262143K->262143K(262144K)]. You PermGenSpace is exhausted and therefore a full GC is done. Therefore increase you PermGenSpace further to solve this problems (perhaps by decreasing you heap space a little bit).

Also don't deploy to often on a production system without restarting Tomcat as this will exhaust your PermGenSpace very fast.

这篇关于Java - Full GC(垃圾收集器)在很短的时间间隔内发生,导致性能下降的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 00:36