You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Joseph Shraibman <jk...@selectacast.net> on 2003/01/23 22:58:28 UTC

Memory leak with ThreadGroups

One of my classes creates a static ThreadGroup.  I notice that when I update a class and 
tomcat reloads that context the ThreadGroup is still around. If the ThreadGroup is still 
around that means the old class is still around, which means that class loader is still 
around.  Why is it still around?  I tried making the ThreadGroup daemon but it didn't help.

I think the fact that the old class loaders are still around goes a long way to explaining 
why tomcat takes up so much memory.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Memory leak with ThreadGroups

Posted by Joseph Shraibman <jk...@selectacast.net>.
Sorry, forgot to mention: tomcat 4.1.18, jdk 1.4.1_01 on linux.

Joseph Shraibman wrote:
> One of my classes creates a static ThreadGroup.  I notice that when I 
> update a class and tomcat reloads that context the ThreadGroup is still 
> around. If the ThreadGroup is still around that means the old class is 
> still around, which means that class loader is still around.  Why is it 
> still around?  I tried making the ThreadGroup daemon but it didn't help.
> 
> I think the fact that the old class loaders are still around goes a long 
> way to explaining why tomcat takes up so much memory.
> 
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Memory leak with ThreadGroups

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 23 Jan 2003, Joseph Shraibman wrote:

> Date: Thu, 23 Jan 2003 16:58:28 -0500
> From: Joseph Shraibman <jk...@selectacast.net>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: tomcat-user@jakarta.apache.org
> Subject: Memory leak with ThreadGroups
>
> One of my classes creates a static ThreadGroup.  I notice that when I
> update a class and tomcat reloads that context the ThreadGroup is still
> around. If the ThreadGroup is still around that means the old class is
> still around, which means that class loader is still around.  Why is it
> still around?  I tried making the ThreadGroup daemon but it didn't help.
>
> I think the fact that the old class loaders are still around goes a long
> way to explaining why tomcat takes up so much memory.
>

If your application creates new threads (and/or thread groups), then it's
*your* problem to cleam them up when the application shuts down, not
Tomcat's.  Tomcat is only responsible for cleaning up its own threads.

A very easy way to deal with this is create a ServletContextListener and
clean up all your application threads in the contextDestroyed() method.

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>