wood burning stoves 2.0*
The moose likes Tomcat and the fly likes Tomcat memory leak (Mac OS X)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat memory leak (Mac OS X)?" Watch "Tomcat memory leak (Mac OS X)?" New topic
Author

Tomcat memory leak (Mac OS X)?

Donald Winston
Greenhorn

Joined: Jul 16, 2010
Posts: 16
catalina.out:
...
Aug 31, 2010 12:28:39 PM org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
Aug 31, 2010 12:28:40 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: A web application appears to have started a thread named [Poller SunPKCS11-Darwin] but has failed to stop it. This is very likely to create a memory leak.
Aug 31, 2010 12:28:40 PM org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080

It says SEVERE but is this really something I should be worried about?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15957
    
  19

Well, it's an indication of sloppy application programming, but nobody gets worried about that these days.


Customer surveys are for companies who didn't pay proper attention to begin with.
Donald Winston
Greenhorn

Joined: Jul 16, 2010
Posts: 16
Not by me. There's nothing I'm doing that would cause this. It's difficult to create a "memory leak" in Java.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15957
    
  19

Donald Winston wrote:Not by me. There's nothing I'm doing that would cause this. It's difficult to create a "memory leak" in Java.


I wish. I spent an entire month tracking down a memory leak several years back. Turned out an Oracle "cache" class was no such thing. By my definition at least, a cache includes an aging mechanism that limits how much data it contains. This particular "cache" was in fact a bottomless pit. Until the JVM ran out of memory about 4 days into a run.

More recently (yesterday!), I got a call for help from an old colleague because something in their webapp is leaking memory.

Occasionally, people even pay me to find that sort of stuff. Or they just schedule nightly reboots.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

According to your log files, you are trying to shutdown Tomcat itself, and that particular thread did not shutdown in the time frame that Tomcat thought was reasonable given that it was shutting itself down.

If this were your own application, I would try to use the admin panel to remove that application from a Tomcat instance that is still running - see if the message occurs then. If it does, then you have a problem with your own application leaving threads running (which will cause both a memory leak and reduce the number of threads in the pool).

I think that particular thread is one that comes with Tomcat, and is used for cryptographic key storage. As such, it is not meant to be taken in/out of service. So the fact that it failed to shut down instantly the moment that Tomcat asked it to shut down is not necessarily a problem. In fact it may even be desirable: if there is some other application relying on PKCS11 that has not yet started to shutdown, and all of a sudden the service disappears, it is going to have some major error handling to do (or continue without encryption - eek).


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15957
    
  19

It doesn't come with Tomcat, although with a name like that, it might come with the MacOS JVM.

I'm extremely sceptical, however, that it's "OK" for a thread to be tripping an alert like that. If it's a JVM thread, it should be getting its shutdown message only after Tomcat has terminated all the webapps and flushed out all the outstanding requests. Which would make it very unlikely that you'd get a Tomcat error that said "A web application appears to have started a thread " from the WebappClassLoader clearReferencesThreads method.

According to a stack dump someone posted over on one of Apple's support forums, this is a daemon thread. Since it's not part of Tomcat (or at least part of Tomcat 6), and all the messages are claiming it belongs to a webapp, that implies that the webapp didn't terminate the thread properly before the webapp itself indicated that it was done shutting down. This doesn't look like the type of process that should take long to terminate under normal conditions, so chances are that the offending webapp didn't try to terminate the thread at all.

I wouldn't worry too much about memory leaks here, unless the thread is saving up large encryption buffers for a rainy day or something.
 
jQuery in Action, 2nd edition
 
subject: Tomcat memory leak (Mac OS X)?
 
Similar Threads
How do I close a bound socket?
Memory leak detection on shutdown (Mac OS X, Tomcat 6)
mac os x bug?
Error in log: ...have started a TimerThread named
Unload event for Tomcat