tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ronald Klop <ronald-mailingl...@base.nl>
Subject Re: How to start a daemon without getting the warning?
Date Thu, 28 Oct 2010 10:39:23 GMT
You should call timer.cancel() on context stop. You can do this from a ServletContextListener.

Ronald.


Op woensdag, 27 oktober 2010 22:10 schreef Leon Rosenberg <rosenberg.leon@gmail.com>:
> 
>  
> Hello,
> 
> I'm getting following warning with 6.0.29,
> 
> after shutdown:
> SEVERE: The web application [/moskitodemo] appears to have started a
> thread named [MoskitoMemoryPoolReader] but has failed to stop it. This
> is very likely to create a memory leak.
> 
> here's the snapshot of the code that starts the thread:
> 
> 
> public class BuiltInMemoryPoolProducer implements IStatsProducer{
> 
>     /**
>      * Timer instance for this producer type.
>      */
>     private static final Timer timer = new Timer("MoskitoMemoryPoolReader", true);
> 
> ...
> 
>     public BuiltInMemoryPoolProducer(MemoryPoolMXBean aPool){
> 
>         timer.scheduleAtFixedRate(new TimerTask() {
>             @Override
>             public void run() {
>                 readMemory();
>             }
>         }, 0, 1000L*60);
> ...}
> 
> to my knowledge this thread is a daemon. This knowledge is also shared
> by jstack:
> 
> 
> "MoskitoMemoryPoolReader" daemon prio=5 tid=10883f800 nid=0x11a9b2000
> in Object.wait() [11a9b1000]
>    java.lang.Thread.State: TIMED_WAITING (on object monitor)
>     at java.lang.Object.wait(Native Method)
>     - waiting on <10a1120d0> (a java.util.TaskQueue)
>     at java.util.TimerThread.mainLoop(Timer.java:509)
>     - locked <10a1120d0> (a java.util.TaskQueue)
>     at java.util.TimerThread.run(Timer.java:462)
> 
> So, how can I avoid this warning and where's the bug.
> 
> regards
> Leon
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message