I am a developer of the tool named Plumbr, which detects memory leaks in user applications. Quite a few of our clients got reports about WebappClassLoader being retained after application undeploy. Classloader is retained in "clBindings" static field of org.apache.naming.resources.DirContextURLStreamHandler class. This prevents application's class loader from being garbage collected and eventually leads to OutOfMemoryError: PermGen. Unfortunately, I have no steps to reproduce the issue.
Hmm. For this to happen an exception would have to be thrown during web application stop that prevented the code that de-registers the associated class loader from being called. 8.0.x is immune to this issue because the registration and deregistration code has been removed as part of the refactoring of resource handling. I've been through the 7.0.x code and I can't see any obvious way to trigger this. All the obvious exceptions that could trigger the problem are caught, logged and not re-thrown. The only exceptions excluded from the process are fatal to the JVM anyway. I do see a possible way to trigger this memory leak in 6.0.x but I need to do some testing to confirm it.
Confirmed. A filter that throws an unchecked exception on destroy can trigger this. This issue has been fixed in 7.0.x. I'll look at putting together a proposal to back-port the changes to 6.0.x
I've back-ported the fix and tested that it works. The fix has been proposed for 6.0.x.
This has been fixed in 6.0.x and will be included in 6.0.40 onwards.