On Sun, May 26, 2013 at 3:14 PM, Caldarale, Charles R < chuck.caldar...@unisys.com> wrote:
> > From: Leon Rosenberg [mailto:rosenberg.l...@gmail.com] > > Subject: Re: Exeptions after upgrading to tomcat 7 > > > Remove following lines from server.xml: > > <!-- Prevent memory leaks due to use of particular java/javax APIs--> > > <Listener > > className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> > > <Listener > > className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> > > This is akin to burying one's head in the sand. It would be much better > to fix the actual problem by shutting down the auxiliary thread with an > appropriate listener. Sloppy programming should not be encouraged. > Chuck, with all respect, this is easier said than done. First we are talking about a ThreadLocal, not Thread. It's tomcat who shuts the threads done due to shutdown, not the app and not the library. Now what is the negative impact of leaving a not-cleaned-up ThreadLocal? - Memory footprint? Well, we are talking about few small objects, if the app has millions of threads it probably has other problems. - Garbage? Yes, but not more than any other Thread variable, it will be collected by the GC once the Thread is collected. - Reentrance? Any lib or code that uses ThreadLocals should initialize them properly. On the other hand efforts to clean it up. You have to provide your own mechanism to clean up ThreadLocals someone else created, because most libs aren't written for redeployment and simple don't care. If they did, they would provide cleanup interfaces to their libs, making them harder to use, but what for? Cleaning ThreadLocals up is a bit like writing destructors. Further, where is the safe place to actually clean up a ThreadLocal The same you created it? So if you want to ensure that you have your threadlocal where you need it, you would set it up in filter, before chain.doFilter() and clean it up in the finally block? Wait, what about forwarded calls? They do not pass a filter, so your code would have to care how it's been called. So RequestListener remains and it will surely have it gotcha's too ;-) All in one, a lot of hustle and bustle, and what for? To clean up 200 bytes faster? Maybe I'm missing something here, but I never seen how ThreadLocal does real harm, neither I can imagine it, please enlighten me ;-) regards Leon > > - Chuck > > > THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY > MATERIAL and is thus for use only by the intended recipient. If you > received this in error, please contact the sender and delete the e-mail and > its attachments from all computers. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >