【问题标题】:Failed to stop the worker thread, likely to create a Memory leak.无法停止工作线程,可能会造成内存泄漏。
【发布时间】:2012-07-10 12:59:10
【问题描述】:

我正在使用实现 ServletContextListener 的 servlet 来启动石英调度程序实例@starup。在 contextDestroyed() 方法中,调度程序实例被停止。

@Override
public void contextDestroyed(ServletContextEvent sce) {
    try {
        Scheduler scheduler = QuartzSchedulerUtil.getCurrentScheduler();
        scheduler.shutdown(true);
        // Sleep for a bit so that we don't get any errors
        Thread.sleep(1000);
        Driver mySqlDriver = DriverManager.getDriver(hibernateConnectionUrl);
        DriverManager.deregisterDriver(mySqlDriver);
    } catch (SchedulerException ex) {
        Logger.getLogger(QuartzServlet.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InterruptedException ex) {
        Logger.getLogger(QuartzServlet.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SQLException ex) {
        Logger.getLogger(QuartzServlet.class.getName()).log(Level.SEVERE, null, ex);
    }        
    System.out.println("THE QUARTZ APP STOPPED");
}

但是在部署应用程序时,我会收到内存泄漏警告,指出woker 线程没有停止。

Jul 10, 2012 3:46:12 PM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads SEVERE: The web application [/latest-raisin]
appears to have started a thread named [Timer-0] but has failed to
stop it. This is very likely to create a memory leak.

Jul 10, 2012 3:46:12 PM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads SEVERE: The web application [/latest-raisin]
appears to have started a thread named 
[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but
has failed to stop it. This is very likely to create a memory leak.

Jul 10, 2012 3:46:12 PM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads SEVERE: The web application [/latest-raisin]
appears to have started a thread named
[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but
has failed to stop it. This is very likely to create a memory leak.

Jul 10, 2012 3:46:12 PM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads SEVERE: The web application [/latest-raisin]
appears to have started a thread named
[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] but
has failed to stop it. This is very likely to create a memory leak.

我尝试了帖子中提到的解决方案 - http://forums.terracotta.org/forums/posts/list/15/4341.page 但是在取消部署应用程序时仍然会收到严重的内存泄漏警告。

【问题讨论】:

标签: java tomcat servlets quartz-scheduler


【解决方案1】:

您可以设置org.quartz.scheduler.interruptJobsOnShutdown 中的属性以在您想要关闭时中断作业(如果它们仍在执行中)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-14
    • 2014-05-13
    • 1970-01-01
    • 2013-03-15
    • 2012-03-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多