1

I have a problem with a Vaadin application, it creates some threads and Tomcat says that they could lead a memory leak problems. I don't create threads in a explicit way.

SEVERE: The web application [/MyApp] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.
ott 29, 2012 9:52:00 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

and:

SEVERE: The web application [/MyApp] created a ThreadLocal with key of type [org.apache.axiom.util.UIDGenerator$1] (value [org.apache.axiom.util.UIDGenerator$1@1f7b22b]) and a value of type [org.apache.axiom.util.UIDGeneratorImpl] (value [org.apache.axiom.util.UIDGeneratorImpl@d25438]) 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.
ott 29, 2012 9:52:00 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/MyApp] created a ThreadLocal with key of type [org.apache.axiom.util.UIDGenerator$1] (value [org.apache.axiom.util.UIDGenerator$1@1f7b22b]) and a value of type [org.apache.axiom.util.UIDGeneratorImpl] (value [org.apache.axiom.util.UIDGeneratorImpl@975b37]) 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.

This let the application very unstable.

During the development process this is the first time I have this error.

How can avoid these problems?

Johan
  • 74,508
  • 24
  • 191
  • 319
gdantimi
  • 378
  • 3
  • 9
  • 20

1 Answers1

2

Neither of these issues have anything to do with Vaadin at all.

You (or a library you are using) have created a java.util.Timer but has not cancelled it.

In addition, the "Threadlocal" issue appears to be caused by Apache Axiom, and appears to be fixed in Axiom 1.2.12 (See http://ws.apache.org/axiom/ and http://ws.apache.org/axiom/)

Charles Anthony
  • 3,155
  • 17
  • 21
  • Maybe a library, not me explicitly. How can I find the library who create that thread? Can be Vaadin to create that thread? Thank you for the Axiom suggest – gdantimi Oct 29 '12 at 13:22
  • I'm afraid there's no *easy* way to find the library that might have created the timer. You might be able to do some yucky hacky work by placing your own debug version of java/util/Timer into WEB-INF/classes and throwing a RunTimeException in the constructor - but that's all I can think of. – Charles Anthony Oct 29 '12 at 13:31
  • ok, maybe it's Vaadin that create something. Now I will try new Axiom's librearies to check if I can avoid al least the second error. Thank you. – gdantimi Oct 29 '12 at 14:13
  • Nothing, same problem with axiom. I imported new libraries but the same error is thrown. – gdantimi Oct 29 '12 at 14:16
  • I've just search the source of Vaadin 6.7.6, and it defintely does *not* create any server side Timer threads. (I'm using both Tomcat & Vaadin, and have never seen the "started a thread named [Timer-0]" issue.) Here is the Axiom bug report : https://issues.apache.org/jira/browse/AXIOM-354. It is identical to the problem you are mentioning. Are you sure that you removed the old jars from your webapp? – Charles Anthony Oct 29 '12 at 15:30
  • Yes sure. If it is not a Vaadin problem (I use 6.7.9) maybe I need to delete ALL libs and re-import them I read about the axiom problem, but I'm using an axis2 version with axiom .12 version so I don't understand. – gdantimi Oct 29 '12 at 15:46
  • I think the timer is also created by Axiom (see http://svn.apache.org/viewvc/webservices/commons/tags/axiom/1.2.12/modules/axiom-api/src/main/java/org/apache/axiom/attachments/AttachmentCacheMonitor.java?revision=1142221&view=markup). If you want to eliminate that message, you might want to call AttachmentCacheMonitor.getAttachmentCacheMonitor().setTimeOut(0) when your web app closes down (via a ContextListener). In the scheme of things, I suspect it's actually not really a big deal though. – Charles Anthony Oct 29 '12 at 16:11