最近我在我的Web应用程序中遇到了这个错误:
java.lang.OutOfMemoryError:PermGen空间
这是在Tomcat 6和JDK 1.6上运行的典型Hibernate/JPA + IceFaces/JSF应用程序.显然,重新部署应用程序几次后就会发生这种情况.
导致它的原因以及可以采取哪些措施来避免它?我该如何解决这个问题?
有没有人有一个例子如何做到这一点?它们是由垃圾收集器处理的吗?我正在使用Tomcat 6.
由于Tomcat中的孤立线程,我遇到了内存泄漏.特别是,似乎Guice和JDBC驱动程序没有关闭线程.
Aug 8, 2012 4:09:19 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: A web application appears to have started a thread named [com.google.inject.internal.util.$Finalizer] but has failed to stop it. This is very likely to create a memory leak.
Aug 8, 2012 4:09:19 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: A web application appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.
Run Code Online (Sandbox Code Playgroud)
我知道这与其他问题(例如这个问题)类似,但在我的情况下,"不要担心它"的答案是不够的,因为它给我带来了问题.我有CI服务器定期更新此应用程序,并且在6-10次重新加载后,CI服务器将挂起,因为Tomcat内存不足.
我需要能够清除这些孤立的线程,以便我可以更可靠地运行我的CI服务器.任何帮助,将不胜感激!
我将tomcat配置为使用不同的外部开源.
但是,在tomcat运行几分钟后,我得到:
严重:Web应用程序[/ MyProject]创建了一个ThreadLocal,其键为[java.lang.ThreadLocal](值为[java.lang.ThreadLocal@1b3f02f]),值为[org.apache.axis.MessageContext](值[org.apache.axis.MessageContext@5dbd4e])但在Web应用程序停止时无法将其删除.这很可能造成内存泄漏.
什么可能导致它?
我在哪里看?它可能是Tomcat上的数据池吗?
什么是Tomcat中的线程?
EDITED
这是我的完整痕迹.该应用程序似乎在它仍在运行时重新加载其上下文 - 我不知道为什么!
Mar 13, 2011 10:56:12 PM org.apache.catalina.core.StandardContext reload
INFO: Reloading this Context has started
Mar 13, 2011 10:56:12 PM org.apache.catalina.core.StandardWrapper unload
INFO: Waiting for 1 instance(s) to be deallocated
Mar 13, 2011 10:56:13 PM org.apache.catalina.core.StandardWrapper unload
INFO: Waiting for 1 instance(s) to be deallocated
Mar 13, 2011 10:56:14 PM org.apache.catalina.core.StandardWrapper unload
INFO: Waiting for 1 instance(s) to be deallocated
Mar 13, 2011 10:56:14 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root …Run Code Online (Sandbox Code Playgroud) 当tomcat关闭时,我在catalina.out日志文件中收到以下消息.我正在使用Tomcat 7.x和Tomcat JDBC数据源.
Mar 26, 2013 1:17:52 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/my_webapp] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Mar 26, 2013 1:17:52 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/my_webapp] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory …Run Code Online (Sandbox Code Playgroud) tomcat ×3
java ×2
memory-leaks ×2
spring ×2
apache ×1
datasource ×1
exception ×1
java-6 ×1
mysql ×1
permgen ×1
thread-local ×1
tomcat7 ×1