Is there a way to avoid undeployment memory leaks in Tomcat?

If you want to make sure not to cause leaks you have to do the following.

If you want to make sure not to cause leaks you have to do the following: Make sure your web application does not use any java classes that are in the web container shared libraries. If you have any shared libraries, make sure there is no strong references to the objects in those libraries Avoid using static variables, especially on java objects like HashTable, Sets, etc. If you need to, make sure that you call remove to release the objects with the maps, lists... Here is also a good article on ThreadLocal and MemoryLeaks - blog.arendsen.net/index.php/2005/02/22/t....

Good info! I tried making a very simple app without any 3rd party or shared libs and did not see the same symptoms I outlined above. The only problem is that a "real world" app will likely have some memory leaks somewhere with the use of 3rd party libs.So I guess it all comes down to the developers somewhere along the line.

I'm sure we could all make improvements: Tomcat, our Apps, Libraries... – sisslack Dec 30 '10 at 22:03 1 Does anybody know more about the effect of dynamic byte code generation as it is used by many XML serializer, Tapestry? Do these libraries properly unload? – Codo Dec 30 '10 at 23:06 Ok, I was hasty in saying I didn't see the same symptoms.

Maybe my test app was too small to notice. I tested with the Tomcat Examples App, and again I saw PermGen filling up and the loaded classes never returned to the baseline after undeployment. I understand that PermGen is used to store metadata about loaded classes.

So I would think that an undeployment should cause Tomcat to drop class references for an app and the GC should clear them and their metadata up right? Even if my classes contain strong references to other classes, shouldn't they die when Tomcat unloads the parent classes? – sisslack Jan 1 at 9:12 Sorry for the back-and-forth, but after some more research and a crash course in profiling, I realized I was confusing class unloading with object destruction.

I expected to see class counts reducing as I updeployed applications from Tomcat. Please see my update on the question. Also when I hit "find leaks" it did not report anything after undeploying the the example app.

– sisslack Jan 3 at 23:29.

Tomcat 7 is supposed to bring improvements in this area. See Features of Apache Tomcat 7, section titled No More Leaks! They believe they can now cope with a lot of memory leaks caused by the web applications.

Unfortunately, it's still in beta. Other than that, I can just say that I've made the same experience and haven't found a solution. Deploying usually requires restarting Tomcat afterwards.

I have no idea who the culprit is: my web application, Tomcat, Tapestry or several of them.

Color me shocked! A section entitle "No More Leaks! "... Does this mean Tomcat used to have leaks?

I'm socked. Just shocked. Upvote my question here: stackoverflow.Com/questions/4400311 – SyntaxT3rr0r Dec 30 '10 at 18:51.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions