javaee / metro-jax-ws

https://javaee.github.io/metro-jax-ws/
Other
132 stars 68 forks source link

Memory leak on ThreadLocalContainerResolver #1145

Open glassfishrobot opened 10 years ago

glassfishrobot commented 10 years ago

On com.sun.xml.ws.client.dispatch.DispatchImpl.invoke(T), an invocation to containers.get on thread local variable is done but there is no invocation to the remove method to detach the thread local variable from the current thread. I think that the remove should be called inside the com.sun.xml.ws.api.server.ThreadLocalContainerResolver.exitContainer(Container) method instead of using the set. I attach a screenshot where with MAT you can see the leak (we have already undeployed and removed the application from WLS12c)

Environment

Tomacat 7.0.50, Weblogic 12.1.2

Affected Versions

[2.2.7, 2.2.8]

glassfishrobot commented 10 years ago

Reported by grifo85

glassfishrobot commented 10 years ago

grifo85 said: I'm not able to attach the image, sorry. If you need more information, tell me how I can send you the details. thanks a lot.

glassfishrobot commented 10 years ago

hartmannt said: I have the same issue with apache-tomcat-7.0.55 and JAXWS 2.2.8 (Java is 1.7.0_51b13 on Win7 64bit)

Aug 28, 2014 6:03:28 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/xxx] created a ThreadLocal with key of type [com.sun.xml.ws.api.server.ThreadLocalContainerResolver$1] 
(value [com.sun.xml.ws.api.server.ThreadLocalContainerResolver$1@77d943c1]) 
and a value of type [com.sun.xml.ws.api.server.Container.NoneContainer] 
(value [com.sun.xml.ws.api.server.Container$NoneContainer@3a3607e0]) but failed to remove it when the web
application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
glassfishrobot commented 9 years ago

michael-o said: This is a terrible, pain in the ass experience, I have to reboot Tomcat on a regular basis. The entire JVM locks up.

glassfishrobot commented 7 years ago

This issue was imported from java.net JIRA JAX_WS-1145

Stexxen commented 6 years ago

I now get this problem with Tomcat 9 on JDK 11, as I've had to start using this implementation of JaxWS for obvious reasons.

24-Aug-2018 01:05:41.283 SEVERE [main] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [xxxx] created a ThreadLocal with key of type [com.sun.xml.ws.api.server.ThreadLocalContainerResolver$1] (value [com.sun.xml.ws.api.server.ThreadLocalContainerResolver$1@5709e10b]) and a value of type [com.sun.xml.ws.api.server.Container.NoneContainer] (value [com.sun.xml.ws.api.server.Container$NoneContainer@114badf0]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
24-Aug-2018 01:05:41.285 SEVERE [main] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [xxxx] created a ThreadLocal with key of type [com.sun.xml.ws.api.server.ThreadLocalContainerResolver$1] (value [com.sun.xml.ws.api.server.ThreadLocalContainerResolver$1@5709e10b]) and a value of type [com.sun.xml.ws.api.server.Container.NoneContainer] (value [com.sun.xml.ws.api.server.Container$NoneContainer@114badf0]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
24-Aug-2018 01:05:41.286 SEVERE [main] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [xxxx] created a ThreadLocal with key of type [com.sun.xml.ws.api.server.ThreadLocalContainerResolver$1] (value [com.sun.xml.ws.api.server.ThreadLocalContainerResolver$1@5709e10b]) and a value of type [com.sun.xml.ws.api.server.Container.NoneContainer] (value [com.sun.xml.ws.api.server.Container$NoneContainer@114badf0]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
24-Aug-2018 01:05:41.288 SEVERE [main] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [xxxx] created a ThreadLocal with key of type [com.sun.xml.ws.api.server.ThreadLocalContainerResolver$1] (value [com.sun.xml.ws.api.server.ThreadLocalContainerResolver$1@5709e10b]) and a value of type [com.sun.xml.ws.api.server.Container.NoneContainer] (value [com.sun.xml.ws.api.server.Container$NoneContainer@114badf0]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
24-Aug-2018 01:05:41.289 SEVERE [main] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [xxxx] created a ThreadLocal with key of type [com.sun.xml.ws.api.server.ThreadLocalContainerResolver$1] (value [com.sun.xml.ws.api.server.ThreadLocalContainerResolver$1@5709e10b]) and a value of type [com.sun.xml.ws.api.server.Container.NoneContainer] (value [com.sun.xml.ws.api.server.Container$NoneContainer@114badf0]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
24-Aug-2018 01:05:41.290 SEVERE [main] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [xxxx] created a ThreadLocal with key of type [com.sun.xml.ws.api.server.ThreadLocalContainerResolver$1] (value [com.sun.xml.ws.api.server.ThreadLocalContainerResolver$1@5709e10b]) and a value of type [com.sun.xml.ws.api.server.Container.NoneContainer] (value [com.sun.xml.ws.api.server.Container$NoneContainer@114badf0]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

They all seem to be holding onto the same NoneContainer so I expect the memory implications are minimal, but ThreadLocals and Tomcat have always best frenemies..... ;-)

This section below does not get called on Tomcat shutdown. Should it?

https://github.com/javaee/metro-jax-ws/blob/74e03b3a64a2b65442383be932f917e6d63a4176/jaxws-ri/rt/src/main/java/com/sun/xml/ws/api/server/ThreadLocalContainerResolver.java#L86-L92