简体   繁体   English

Tomcat 8内存泄漏

[英]Tomcat 8 memory leak

I'm developing Java Web application using Spring/Spring Boot/MySQL and deployed it to Tomcat 8. 我正在使用Spring / Spring Boot / MySQL开发Java Web应用程序并将其部署到Tomcat 8。

In Tomcat Web Application Manager I click Reload button and after successful redeploy - Find Leaks button and have a following message: 在Tomcat Web应用程序管理器中,我单击“ Reload按钮,并在成功重新部署后Find Leaks按钮,并显示以下消息:

The following web applications were stopped (reloaded, undeployed), but their
classes from previous runs are still loaded in memory, thus causing a memory
leak (use a profiler to confirm):
/domain-api
/domain-api

My Tomcat log does not contain messages about possible memory leaks.. 我的Tomcat日志不包含有关可能的内存泄漏的消息。

Looks like right now I have a 2 instances of my application(domain-api) up and running.. How to check it and how to fix it ? 看起来现在我有2个实例正在运行我的应用程序(domain-api)。如何检查和修复它?

This has not to mean, that your application has a memory leak. 这并不意味着您的应用程序存在内存泄漏。 The message in the tomcat manager just means, that there are still some classes from a previously deployed web application loaded that have not yet been garbage collected. tomcat管理器中的消息仅表示,仍然有一些来自以前部署的Web应用程序的类已加载,这些类尚未被垃圾回收。

If it is not a memory leak then this warning could be removed by setting your permGenSpace to a lower value. 如果不是内存泄漏,则可以通过将permGenSpace设置为较低的值来消除此警告。 This will force the GC to unload all classes after you redeploy your app. 重新部署应用程序后,这将强制GC卸载所有类。

An other way to ensure you have no memory leak is to redeploy the app a few times and the create a heapdump and analyze it with a profiler like Eclipse Memory Analyzer . 确保您没有内存泄漏的另一种方法是重新部署该应用程序几次,并创建一个heapdump并使用诸如Eclipse Memory Analyzer之类的分析器对其进行分析 There you should look for instances of the type WebappClassLoader that cannot be garbage collected. 在那里,您应该查找无法被垃圾收集的WebappClassLoader类型的实例。

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

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