tomcat停止出现内存泄漏
SEVERE: The web application [] registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
SEVERE: The web application [] 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.
Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-1] but has failed to stop it. This is very likely to create a memory leak.
Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-2] but has failed to stop it. This is very likely to create a memory leak.
Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-3] but has failed to stop it. This is very likely to create a memory leak.
Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-4] but has failed to stop it. This is very likely to create a memory leak.
Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-5] but has failed to stop it. This is very likely to create a memory leak.
Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-6] but has failed to stop it. This is very likely to create a memory leak.
Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-7] but has failed to stop it. This is very likely to create a memory leak.
Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-8] but has failed to stop it. This is very likely to create a memory leak.
Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-9] but has failed to stop it. This is very likely to create a memory leak.
Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-10] but has failed to stop it. This is very likely to create a memory leak.
Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The 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.
以上是tomcat报出的错误信息。
原因分析:通过查询大量资料,同时结合自己的项目情况,分析得出引起tomcat memory leak 的原因有:
1、jdbc Driver在tomcat运行时进行注册,但是当tomcat停止时没有解除注册;
2、使用quartz跑定时任务时,tomcat停了,quartz的线程没有停掉;
3、web 容器重启一个叫Abandoned connection cleanup thread的线程失败.
解决办法:
1、用脚本语言代替quartz的定时任务或将quartz与业务代码剥离开来;
2、手动反注册jdbc驱动,清理Abandoned connection cleanup thread。
importcom.mysql.jdbc.AbandonedConnectionCleanupThread;importjavax.servlet.ServletContextEvent;importjavax.servlet.ServletContextListener;importjava.sql.DriverManager;importjava.sql.SQLException;/***Createdbyyinguoon2018-06-26.*/publicclassQuartzContextListenerimplementsServletContextListener{@OverridepublicvoidcontextDestroyed(ServletContextEventarg0){System.out.println("webServicestop");try{while(DriverManager.getDrivers().hasMoreElements()){DriverManager.deregisterDriver(DriverManager.getDrivers().nextElement());}System.out.println("jdbcDriverclose");AbandonedConnectionCleanupThread.shutdown();System.out.println("cleanthreadsuccess");}catch(SQLExceptione){e.printStackTrace();}catch(InterruptedExceptione){e.printStackTrace();}}@OverridepublicvoidcontextInitialized(ServletContextEventarg0){System.out.println("webServicestart");}}
最后再说一点,解决方案千篇一律,还是要具体问题具体分析!!!
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。