You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Noble Paul നോബിള്‍ नोब्ळ् <no...@gmail.com> on 2008/10/16 07:26:50 UTC

Memory leak from threadlocal for hot deployment

If I store an application object in ThreadLocal and do hot deployment
it prevents the old classloader from getting GCed . Why can't Tomcat
refresh it's threadpool after every app restart?
--Noble

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Memory leak from threadlocal for hot deployment

Posted by Ronald Klop <ro...@base.nl>.
As far as I know the threads from the connector are shared between webapps.
So how would Tomcat know which objects in the threadlocals are from which webapp?

Or should Tomcat destroy all threadlocals of webapp A if I reload webapp B?

Ronald.


Op vrijdag, 17 oktober 2008 om 8:19 uur schreef Tomcat Users List <us...@tomcat.apache.org>:
> 
> 
> Subject: Re: Memory leak from threadlocal for hot deployment
> Date: Fri Oct 17 08:19:11 CEST 2008
> From: Noble Paul നോബിള്‍ नोब्ळ् <no...@gmail.com>
> 
> 
> While it is possible to do so (If I know it) wouldn't it be more
> elegant if Tomcat handles it automatically. It is hard to educate the
> users to cleanup their threadlocals
> 
> Recreating the threads in threadpool once per restart is not really
> expensive and users must be fine with that
> 
> 
> 
> On Thu, Oct 16, 2008 at 2:04 PM, Leon Rosenberg
> <ro...@googlemail.com> wrote:
> > Err, why can't you reset the object after usage or at next redeploy?
> > Leon
> >
> > On Thu, Oct 16, 2008 at 7:26 AM, Noble Paul നോബിള്‍ नोब्ळ्
> > <no...@gmail.com> wrote:
> >> If I store an application object in ThreadLocal and do hot deployment
> >> it prevents the old classloader from getting GCed . Why can't Tomcat
> >> refresh it's threadpool after every app restart?
> >> --Noble
> >>
> >> ---------------------------------------------------------------------
> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >
> 
> 
> 
> -- 
> --Noble Paul
> 
> 
> 
> 


Re: Memory leak from threadlocal for hot deployment

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Noble,

Noble Paul നോബിള്‍ नोब्ळ् wrote:
> While it is possible to do so (If I know it) wouldn't it be more
> elegant if Tomcat handles it automatically. It is hard to educate the
> users to cleanup their threadlocals.

They must be educated. Un-cared-for ThreadLocals can really screw things
up, especially if they are constantly added and never removed.

They can also be a security concern: if you don't remove your data from
the thread, how can you know what someone else's code will do with your
data?

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkj4/9kACgkQ9CaO5/Lv0PAXOgCff9NABE7A/lkD5FXnz46UK37N
hRMAnRTm4eqS3pC11tvZCsmLxE+Bg52M
=lQb1
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Memory leak from threadlocal for hot deployment

Posted by Noble Paul നോബിള്‍ नोब्ळ् <no...@gmail.com>.
While it is possible to do so (If I know it) wouldn't it be more
elegant if Tomcat handles it automatically. It is hard to educate the
users to cleanup their threadlocals

Recreating the threads in threadpool once per restart is not really
expensive and users must be fine with that



On Thu, Oct 16, 2008 at 2:04 PM, Leon Rosenberg
<ro...@googlemail.com> wrote:
> Err, why can't you reset the object after usage or at next redeploy?
> Leon
>
> On Thu, Oct 16, 2008 at 7:26 AM, Noble Paul നോബിള്‍ नोब्ळ्
> <no...@gmail.com> wrote:
>> If I store an application object in ThreadLocal and do hot deployment
>> it prevents the old classloader from getting GCed . Why can't Tomcat
>> refresh it's threadpool after every app restart?
>> --Noble
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>



-- 
--Noble Paul

Re: Memory leak from threadlocal for hot deployment

Posted by Leon Rosenberg <ro...@googlemail.com>.
Err, why can't you reset the object after usage or at next redeploy?
Leon

On Thu, Oct 16, 2008 at 7:26 AM, Noble Paul നോബിള്‍ नोब्ळ्
<no...@gmail.com> wrote:
> If I store an application object in ThreadLocal and do hot deployment
> it prevents the old classloader from getting GCed . Why can't Tomcat
> refresh it's threadpool after every app restart?
> --Noble
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>