石英:内存泄漏?

我正在使用Quartz来每小时运行一项工作。 Servlet在Tomcat上运行,我正在使用ServletConextListener来侦听上下文何时被销毁。

当我关闭tomcat时,我收到消息:

“似乎已经启动了一个名为[MyScheduler_Worker-1]的线程,但未能阻止它”。

但后来我看到这个消息:

“[DEBUG] 28 Sep 11:45:26.671 AM MyScheduler_Worker-1 [org.quartz.simpl.SimpleThreadPool]

WorkerThread已关闭。“

那么可以安全地假设这个线程没有内存泄漏?

以下是我的日志的外观:

{SEVERE: The web application [/*************] appears to have started a thread

named [MyScheduler_Worker-1] but has failed to stop it. This is very likely to c

reate a memory leak.

Sep 28, 2011 11:45:26 AM org.apache.catalina.loader.WebappClassLoader clearRefer

encesThreads

SEVERE: The web application [/*************] appears to have started a thread

named [MyScheduler_Worker-2] but has failed to stop it. This is very likely to c

reate a memory leak.

Sep 28, 2011 11:45:26 AM org.apache.catalina.loader.WebappClassLoader clearRefer

encesThreads

SEVERE: The web application [/*************] appears to have started a thread

named [MyScheduler_Worker-3] but has failed to stop it. This is very likely to c

reate a memory leak.

[DEBUG] 28 Sep 11:45:26.671 AM MyScheduler_Worker-2 [org.quartz.simpl.SimpleThre

adPool]

WorkerThread is shut down.



[DEBUG] 28 Sep 11:45:26.671 AM MyScheduler_Worker-1 [org.quartz.simpl.SimpleThre

adPool]

WorkerThread is shut down.



[DEBUG] 28 Sep 11:45:26.671 AM MyScheduler_Worker-3 [org.quartz.simpl.SimpleThre

adPool]

WorkerThread is shut down.

我知道这是一条古老的线索,但如果其他人正在寻找它。

我们一直使用线程的警告,直到我们添加了代码来关闭我们的ServletContextListener.shutDown()方法中的Quartz Scheduler。

关闭调度程序:

            quartzScheduler.shutdown();

            int ct = 0;

            // Try waiting for the scheduler to shutdown. Only wait 30 seconds.
            while(ct < 30) {
                ct++;
                // Sleep for a second so the quartz worker threads die.  This 
                // suppresses a warning from Tomcat during shutdown.
                Thread.sleep(1000);
                if (quartzScheduler.isShutdown()) {
                    break;
                }
            }

您可以认为没有内存泄漏,因为您看到线程关闭消息。 但是,可能会在关闭前通过清理线程来发出警告。

The shutdown-hook plugin catches the event of the JVM terminating, and calls shutdown on the scheduler.

详情: - http://quartz-scheduler.org/documentation/quartz-2.x/configuration/ConfigPlugins

链接地址: http://www.djcxy.com/p/55039.html

上一篇: Quartz : Memory Leak?

下一篇: Embed a web browser in a Python program