2011-09-28 10 views
7

私は毎時ジョブを実行するためにQuartzを使用しています。サーブレットはTomcat上で動作しており、ServletConextListenerを使用して、コンテキストが破棄されたときにリッスンします。石英:メモリリーク?

私はTomcatをシャットダウンすると、私はメッセージを取得する:

は、「[MyScheduler_Worker-1]という名前のスレッドを開始しているように見えますが、それを止めることができませんでした」。

しかし、その後、私はこのメッセージを見る "[DEBUG] 9月28日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. 
+0

Tomcatがシャットダウンにスレッドを石英するのに十分な時間を与えることはないと言われています。しかし、私はまだこれを確認することができませんでした。 – Codo

答えて

0

あなたは、スレッドのシャットダウンメッセージを見るので何のメモリリークがないと仮定することができます。しかし、シャットダウンする前にスレッドをクリアすることによって警告が出る可能性があります。

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

4

私は、これは古いスレッドです知っているが、場合には他の人がそれを探しています。

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; 
       } 
      } 
関連する問題