I'm having the following problem - my application is using Struts(1.1) and Log4J (1.2.7). I run it on tomcat 4.1.24. I use OptimizeIt (www.optimizeit.com) to see what classes weren't garbage collected after I stop or reload my webapplication. I was experiencing memory leaks (but only if I was reloading my webapplication) and tried to investigate further.
I noticed that org.apache.catalina.loader.WebappClassLoader is not removed after I stop/reload my webapplication. Every time I restart my application, the new WebappClassLoader is added to the list of WebappClassLoaders - and they are never get garbage collected.
I debugged this class and the class that is referencing this class loader (org.apache.catalina.loader.WebappLoader) and it looks like all references to this class from the WebappLoader are removed (WebappClassLoaders are stroed in the HashTable in the WebappLoader and when WebappClassLoader is not needed anymore, it's removed from the HashTable). OptimizeIt is showing that "Jakarta Tomcat" is referencing this class, and does not give any details - so I cannot go further than that here.
I created a simple application that consists of 3 servlets 1) HttpServlet- no Log4J, no Struts 2) HttpServlet, Log4J, no Struts 3) Strut's ActionServlet, no Log4J.
For the first one everything works fine - WebappClassLoader is removed after webapplication is stopped. I noticed, that calling the second and the third one I do not always get my WebappClassLoader classes in the list garbage collected instantly, but they disappear after some time (like 15-20 seconds after reloading the webapplication). In my "real" application they do not disappear at all...
You might want to search the archives of the Tomcat User's list for this - there's a link to them at http://tomcatfaq.sourceforge.net; I think this problem has been covered there in the past.