2

ServletContextListener を実装するサーブレットを使用して、クォーツ スケジューラ インスタンス @ 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");
}

しかし、アプリケーションがデプロイされると、waker スレッドが停止していないことを示すメモリ リークの警告が表示されます。

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 しかし、アプリケーションが展開されていないときに、依然として重大なメモリ リークの警告が表示されます。

4

1 に答える 1