-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Sylvain,
On 11/24/11 4:02 PM, Sylvain Laurent wrote: > I don't think this ThreadLocal creates a real leak of classloader. > It would if dayFormat was static. IIRC, ThreadLocal essentially puts a key/value pair in a Map in the Thread. I dunno what kind of reference it is, but I suspect it's a normal, strong reference. That means that the Thread itself retains a reference to the instance of the inner class in my servlet. That's just not going to become available for collection anytime soon. > But you may still see warnings issued by tomcat when the > application is stopped because of this problem > http://wiki.apache.org/tomcat/MemoryLeakProtection#threadLocalPseudoLeak > > After some time and if all the threads of the server are sollicited > sufficiently, the classloader will be eventually collected. I must admit that I haven't instrumented the VM after a redeploy to check to see if the ThreadLocals are eventually restarted. > With tomcat 7, there's no leak since threads are renewed, but you > might still see the warnings. I am using Tomcat 7 -- I had forgotten about that feature. So, I think you're right: the Threads will eventually be trashed and the WebappClassLoader will be discarded. Thanks for pointing that out. > IMHO, you'd rather either stop worrying and recreate a new > SimpleDateFormat, unless actual tests show a real bottleneck. In > that case, go with another implementation like FastDateFormat. It > will be much cleaner than playing with ThreadLocals... Absolutely. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk7PrR8ACgkQ9CaO5/Lv0PC3EQCfTBNGMNCl0Nk882pDrrHMnVWH 3+oAoLbdnk0FgHs907hWSzq+5PsAyASl =mB/F -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org