Leaks?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Leaks?

NoSuchLuke
I'm seeing this multiple times in my Tomcat logs when shutting down my application:

SEVERE: The web application [/app] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@2e4990e8]) and a value of type [org.thymeleaf.ThreadLocalMetadata.ThreadLocalMetadataContainer] (value [org.thymeleaf.ThreadLocalMetadata$ThreadLocalMetadataContainer@53a7c878]) 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.

So, should I be setting a destroy-method on the templateEngine or what?
Reply | Threaded
Open this post in threaded view
|

Re: Leaks?

danielfernandez
Administrator
Hi,

This is an error message issued by Tomcat when performing hot-redeploy of an application that holds ThreadLocal instances of a class loaded by the webapp's classloader (ThreadLocalContainer and ThreadLocalMetadata, in this case).

Tomcat's behaviour is explained here: http://wiki.apache.org/tomcat/MemoryLeakProtection#webappClassInstanceAsThreadLocalValue

Tomcat is making sure that your application is not suffering a leak by refreshing the thread pool when you hot-redeploy your application, so there's nothing you need to do about this and you are completely safe.

Anyway, this behaviour is not correct and Thymeleaf should not be relying on the application server's capability to avoid these kind of leaks, so I've deprecated those ThreadLocal's in 2.0.14-SNAPSHOT. Note that the error messages will not completely dissapear until those variables are definitely removed, which will happen in 2.1.

Regards,
Daniel.
Reply | Threaded
Open this post in threaded view
|

Re: Leaks?

NoSuchLuke
Good to know, thanks.