石英:内存泄漏? [英] Quartz : Memory Leak?

查看:72
本文介绍了石英:内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Quartz 每小时运行一个作业.servlet 在 Tomcat 上运行,我使用 ServletConextListener 来监听上下文何时被销毁.

I am using Quartz to run a job every hour. The servlet is running on Tomcat and I am using the ServletConextListener to listen for when the context is destroyed.

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

When I shut down tomcat, I get the message:

似乎启动了一个名为 [MyScheduler_Worker-1] 的线程,但未能阻止它".

"appears to have started a thread named [MyScheduler_Worker-1] but has failed to stop it".

但后来我看到这条消息:

But later I see this message:

"[DEBUG] 9 月 28 日 11:45:26.671 AM MyScheduler_Worker-1 [org.quartz.simpl.SimpleThreadPool]

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

WorkerThread 已关闭."

WorkerThread is shut down."

那么假设没有内存泄漏是安全的吗?

So is it safe to assume that there is no memory leak because of this thread?

这是我的日志的样子:

{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.

推荐答案

我知道这是一个旧线程,但以防其他人正在寻找它.

I know this is an old thread but in case others are looking for it.

我们一直在获取线程的警告,直到我们在 ServletContextListener.shutDown() 方法中添加了关闭 Quartz 调度程序的代码.

We use to get the warnings of threads all the time until we added code to shutdown the Quartz Scheduler in our ServletContextListener.shutDown() method.

关闭调度程序:

            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;
                }
            }

这篇关于石英:内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆