Tomact8.0 DruidDrive This is very likely to create a memory leak. Stack trace of thread:+quartz关闭线程
2018-01-29 21:53
821 查看
这是tomact8.0重启(重新启动所报的错误)原因是什么?虽然数据库的线程池关闭了,但是有些线程在tomact中并没有关闭,这个并不是在正常关闭的clean的时候,而是在服务器上直接替换项目,不停止tomact部署项目(热部署),由于项目的不断被修改部署测试,tomact中的线程也会越来越多,内存消耗越来越大。在这里吐槽一下“百度大大”前几页的搜索的解决办法不是
1.修改tomact中server.xml中的监听方法<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>这个监听给关了
2.就是关闭tomact ————》clean————》启动tomact(不行的原因你那个是24小时的项目,怎么可能允许你关闭再启动呢?)
3.就是sleep线程等待他关闭(这个最坑我就是被这个困扰了很久,怎么可能自己就关了不做任何处理呢?)
也有解释很透彻的,形容这个为戏台子,已经把台子都拆了,戏子还在唱戏(非常对)但是没有给出代码,作为小白我真的是很痛苦。。其实我感觉方法,大家肯定是知道的不就是再拆台子前面赶走戏子吗?但是肯定不知道具体怎么赶走啊(机关枪?拿脚踹?)所以大神们除了给方法外最好贴上代码让大家学习,不然象我这样的小白会浪费很久时间。
赞扬一下外国人大兄弟 https://stackoverflow.com/questions/3230324/answer/submit
其中4楼TOM大兄弟说的话非常对。结合他的提示和我项目的特点我是做如下处理的:
在web 程序销毁时
public void contextDestroyed(ServletContextEvent servletContextEvent) {
try {
Scheduler scheduler=(Scheduler) SystemContext.getBean("schedulerFactoryBean");//先关闭quartz在spring中的连接,需要自己获取Sping的中quartz工厂如下图所示(先关闭他的原因?如果不关闭他只关闭线程,再重启的时候quartz会再次启动(线程关闭后再次启动)相当于没关线程)
scheduler.shutdown(true);
logger.info("scheduler关闭");
AbandonedConnectionCleanupThread.shutdown(); //关闭jdbc连接池(其实是关闭AbandonedConnectionCleanupThread这一个线 程)
logger.info("AbandonedConnectionCleanupThread关闭");
Scheduler schedulerDefault = StdSchedulerFactory.getDefaultScheduler();//关闭quartz线程(真正的关闭残留在 tomact中的quartz线程)
schedulerDefault.shutdown(true);
logger.info("schedulerDefault :quartz线程关闭");
} catch (Exception e) {
logger.error("线程关闭异常",e);
e.printStackTrace();
}
或许你还有其他的类型的线程为关闭比如Timer啊等等,需要的是找到他关闭,不要不管。
这件事给我的启示是线程是有始有终的在一条“线”开始的时候一定要想好他在何处终结!
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
警告: The web application [/KMIA_ABCM] 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.
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
警告: The web application [/KMIA_ABCM] 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.
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-2] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-3] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-4] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-5] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThread
cdd3
s
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-6] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-7] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-8] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-9] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-10] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_QuartzSchedulerThread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:311)
七月 15, 2016 10:34:10 上午 org.apache.coyote.AbstractProtocol stop
信息: Stopping ProtocolHandler ["http-nio-8088"]
七月 15, 2016 10:34:10 上午 org.apache.coyote.AbstractProtocol stop
信息: Stopping ProtocolHandler ["ajp-nio-8009"]
七月 15, 2016 10:34:10 上午 org.apache.coyote.AbstractProtocol destroy
信息: Destroying ProtocolHandler ["http-nio-8088"]
七月 15, 2016 10:34:10 上午 org.apache.coyote.AbstractProtocol destroy
信息: Destroying ProtocolHandler ["ajp-nio-8009"]
1.修改tomact中server.xml中的监听方法<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>这个监听给关了
2.就是关闭tomact ————》clean————》启动tomact(不行的原因你那个是24小时的项目,怎么可能允许你关闭再启动呢?)
3.就是sleep线程等待他关闭(这个最坑我就是被这个困扰了很久,怎么可能自己就关了不做任何处理呢?)
也有解释很透彻的,形容这个为戏台子,已经把台子都拆了,戏子还在唱戏(非常对)但是没有给出代码,作为小白我真的是很痛苦。。其实我感觉方法,大家肯定是知道的不就是再拆台子前面赶走戏子吗?但是肯定不知道具体怎么赶走啊(机关枪?拿脚踹?)所以大神们除了给方法外最好贴上代码让大家学习,不然象我这样的小白会浪费很久时间。
赞扬一下外国人大兄弟 https://stackoverflow.com/questions/3230324/answer/submit
其中4楼TOM大兄弟说的话非常对。结合他的提示和我项目的特点我是做如下处理的:
在web 程序销毁时
public void contextDestroyed(ServletContextEvent servletContextEvent) {
try {
Scheduler scheduler=(Scheduler) SystemContext.getBean("schedulerFactoryBean");//先关闭quartz在spring中的连接,需要自己获取Sping的中quartz工厂如下图所示(先关闭他的原因?如果不关闭他只关闭线程,再重启的时候quartz会再次启动(线程关闭后再次启动)相当于没关线程)
scheduler.shutdown(true);
logger.info("scheduler关闭");
AbandonedConnectionCleanupThread.shutdown(); //关闭jdbc连接池(其实是关闭AbandonedConnectionCleanupThread这一个线 程)
logger.info("AbandonedConnectionCleanupThread关闭");
Scheduler schedulerDefault = StdSchedulerFactory.getDefaultScheduler();//关闭quartz线程(真正的关闭残留在 tomact中的quartz线程)
schedulerDefault.shutdown(true);
logger.info("schedulerDefault :quartz线程关闭");
} catch (Exception e) {
logger.error("线程关闭异常",e);
e.printStackTrace();
}
不要忘记在web.xml中加入自己的监听事件
<listener><listener-class>com.boostyoung.bocc.listrner.initListener</lisener-class></listener>
或许你还有其他的类型的线程为关闭比如Timer啊等等,需要的是找到他关闭,不要不管。
这件事给我的启示是线程是有始有终的在一条“线”开始的时候一定要想好他在何处终结!
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
警告: The web application [/KMIA_ABCM] 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.
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
警告: The web application [/KMIA_ABCM] 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.
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-2] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-3] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-4] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-5] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThread
cdd3
s
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-6] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-7] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-8] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-9] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_Worker-10] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:568)
七月 15, 2016 10:34:10 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
警告: The web application [/KMIA_ABCM] appears to have started a thread named [DefaultQuartzScheduler_QuartzSchedulerThread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:311)
七月 15, 2016 10:34:10 上午 org.apache.coyote.AbstractProtocol stop
信息: Stopping ProtocolHandler ["http-nio-8088"]
七月 15, 2016 10:34:10 上午 org.apache.coyote.AbstractProtocol stop
信息: Stopping ProtocolHandler ["ajp-nio-8009"]
七月 15, 2016 10:34:10 上午 org.apache.coyote.AbstractProtocol destroy
信息: Destroying ProtocolHandler ["http-nio-8088"]
七月 15, 2016 10:34:10 上午 org.apache.coyote.AbstractProtocol destroy
信息: Destroying ProtocolHandler ["ajp-nio-8009"]
相关文章推荐
- This is very likely to create a memory leak. Stack trace of thread
- SSH框架 Tomcat报错 内存泄漏的解决办法This is very likely to create a memory leak. Stack trace of thread: java.ne
- 警告: The web application [ROOT] appears to have started a thread named [Thread-48] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
- 错误:created a ThreadLocal with key of type ……but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
- but has failed to stop it. This is very likely to create a memory leak(c3p0在Spring管理中,连接未关闭导致的内存溢出)
- tomcat 6.0.44 “has failed to stop it. This is very likely to create a memory leak” 问题调查
- quartzScheduler_Worker-1] but has failed to stop it. This is very likely to create a memory leak解决
- tomcat启动部署APP报错:This is very likely to create a memory leak
- Linux环境Tomcat 启动警告This is very likely to create a memory leak.
- This is very likely to create a memory leak.
- tomcat报错:This is very likely to create a memory leak问题解决
- 由一个自动部署脚本引发的血案。。。This is very likely to create a memory leak
- tomcat启动报错,JDBC注册失败:This is very likely to create a memory leak
- This is very likely to create a memory leak 异常
- This is very likely to create a memory leak 异常
- 内存溢出,无法创建新的本地线程的原因和解决方案 - java.lang.OutOfMemoryError: unable to create new native thread
- Java中OutOfMemoryError与unable to create new native thread(JVM创建大量线程)的关系
- java.lang.OutOfMemoryError: unable to create new native thread无法创建本地线程分析
- Java中OutOfMemoryError与unable to create new native thread(JVM创建大量线程)的关系