Mantis - Hessian
Viewing Issue Advanced Details
4376 major always 02-07-11 05:11 02-26-12 03:51
p_wright  
 
normal  
new 4.0.13  
open  
none    
none  
0004376: Memory leak due to ServiceContext not clearing ThreadLocal
HessianServlet sets up a ServiceContext type for convenience, this uses a ThreadLocal to store an instance of ServiceContext however when the service call completes it does not clean up the ThreadLocal. This dangling ThreadLocal reference prevents Tomcat from freeing the ClassLoader associated with the webapp.

It looks like ServiceContext.end() should call _localContext.remove()
The error message produced by Tomcat 7:


SEVERE: The web application [/hessianwebapp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@655e3dc4]) and a value of type [com.caucho.services.server.ServiceContext] (value [com.caucho.services.server.ServiceContext@e2942da]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
07-Feb-2011 12:56:31 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/hessianwebapp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@655e3dc4]) and a value of type [com.caucho.services.server.ServiceContext] (value [com.caucho.services.server.ServiceContext@36e3fd79]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
07-Feb-2011 12:56:31 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/hessianwebapp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@655e3dc4]) and a value of type [com.caucho.services.server.ServiceContext] (value [com.caucho.services.server.ServiceContext@32162f16]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
07-Feb-2011 12:56:31 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/hessianwebapp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@655e3dc4]) and a value of type [com.caucho.services.server.ServiceContext] (value [com.caucho.services.server.ServiceContext@4e6d670a]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
07-Feb-2011 12:56:31 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/hessianwebapp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@655e3dc4]) and a value of type [com.caucho.services.server.ServiceContext] (value [com.caucho.services.server.ServiceContext@7087e9bf]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
07-Feb-2011 12:56:31 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/hessianwebapp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@655e3dc4]) and a value of type [com.caucho.services.server.ServiceContext] (value [com.caucho.services.server.ServiceContext@6b033450]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
07-Feb-2011 12:56:31 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/hessianwebapp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@655e3dc4]) and a value of type [com.caucho.services.server.ServiceContext] (value [com.caucho.services.server.ServiceContext@1f5fa713]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
07-Feb-2011 12:56:31 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/hessianwebapp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@655e3dc4]) and a value of type [com.caucho.services.server.ServiceContext] (value [com.caucho.services.server.ServiceContext@40d1e07c]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.

Notes
(0005702)
mate   
02-26-12 03:51   
I believe this was fixed in 4.0.23