Amir Taghvayi
Amir Taghvayi

Reputation: 23

tomcat - timer memory leak

I am currently using tomcat7 . my web application has caused a Timer memory leak on stop . the log is :

   SEVERE: A web application appears to have started a TimerThread     
   named [Timer-5] via the java.util.Timer API but has failed to stop it. 
   To prevent a memory leak, the timer (and hence the associated thread) 
   has been forcibly cancelled.   

I am not using java.util.Timer in my web-app.

Upvotes: 1

Views: 2636

Answers (3)

ssedano
ssedano

Reputation: 8432

In tomcat wiki there is an explanation (kind of) and a link to this bug in commons-pool.

The timer stop is optional in tomcat >6.0.27

Upvotes: 0

Amir Taghvayi
Amir Taghvayi

Reputation: 23

This one I am not so certain of. There appears to be an RMI timeout timer, but all of that is part of Tomcat, so it should not be a leak

Upvotes: 0

BalusC
BalusC

Reputation: 1109402

This does not necessarily indicate that your code is using java.util.Timer (which is by the way an extremely bad idea in a Java EE webapp, for the reasons mentioned here). This Timer can also be included as part of any of the libraries supplied in your webapp's /WEB-INF/lib folder. Apparently some library has auto-registered a ServletContextListener or ServletContainerInitializer on webapp's startup wherein the Timer is been created.

You need to investigate which library it is and then fix/remove it accordingly. Extract the JARs to check the enclosed code, or remove them one by one. Once the culprit is found, I'd surely report to the library's maintainers that using Timer is absolutely not recommended in a Java EE webapp and that they have to fix it.

Upvotes: 2

Related Questions