Details
Description
Analyzing heap dumps of Tomcat running my Wicket webapp shows that the webapp ClassLoader is not becoming unreferenced and garbage-collectable when the webapp is undeployed. The cause is the RequestContext ThreadLocal - this ThreadLocal is not being cleared before the WicketFilter returns control to Tomcat - as a result, Wicket RequestContext instances remain attached to Tomcat theadpool threads. Thus the reference chain of Thread -> threadLocalsMap -> RequestContext instance prevents the JVM from unloading the undeployed webapp classes.