|
From: Patrick B. <pbu...@gm...> - 2004-10-22 16:20:12
|
I just want to get this straight, since we run into this memory leak a lot here when redeploying our app a lot in development: The leak is caused by ThreadLocals that aren't cleaned up in Dom4j? If so, I wonder what could be done in the Dom4j library to help this situation, like maybe an API call that tells it to "clean up"? Thanks, Patrick On Fri, 22 Oct 2004 00:50:33 -0400, Guillaume Poirier <gpo...@gl...> wrote: > ----- Original Message ----- > From: "Guillaume Poirier" <gpo...@gl...> > To: <spr...@li...> > Sent: Thursday, October 21, 2004 6:25 PM > Subject: Re: [Springframework-developer] CGLIB memory usage within class > loader > > >> I only wish A) there was a way to explicitly blow away the classloader > >> or B) have hibernate be redeployable. One option is to place all the > >> Hibernate related classes inside Tomcat's shared Classloader. This > >> might reduce the amount of times I need to restart. > > > > Well, if you care enough, I'm pretty sure you could create a > > ContextListener > > that would cleanup when the context is destroyed. It would invole > > reflection > > to hack in private fields of the Threads though, so the solution might > > fail > > in different JVM, and wouldn't work well with SecurityManagers. Basically, > > what you would have to do is to get the list of all the system's thread > > (through > > ThreadGroup), and for each of them, iterate the "threadLocals" map, and > > the "inheritableThreadLocals", to cleanup any instance for which the > > ClassLoader is the current webapp or of child of it. > > > > You might also have to cleanup a few other things though, such as if you > > have > > any JDBC drivers in your webapp's ClassLoader, they need to be explicitly > > unregistered, otherwise they will not be garbage collected. > > > > I create a prototype of a ContextListener that does that if you want. > > > > Guillaume |