Shutdown memory leaks according to Tomcat?

149 views
Skip to first unread message

Chris

unread,
Mar 26, 2011, 9:03:17 AM3/26/11
to Ebean ORM
Hi

When redploying my application, it seems some things are not being
removed properly. Do I need to call anything specific myself to
shutdown Ebean correctly?

For example Tomcat tells me the following:
SEVERE: A web application appears to have started a thread named
[EbeanBackgroundThread] but has failed to stop it. This is very likely
to create a memory leak.
26-Mar-2011 12:59:03 org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: A web application appears to have started a thread named
[Ebean-db-periodic-1] but has failed to stop it. This is very likely
to create a memory leak.
26-Mar-2011 12:59:03 org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: A web application appears to have started a thread named
[Ebean-db-LuceneManager] but has failed to stop it. This is very
likely to create a memory leak.
26-Mar-2011 12:59:03 org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: A web application appears to have started a thread named
[Ebean-db.2] but has failed to stop it. This is very likely to create
a memory leak.
26-Mar-2011 12:59:03 org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: A web application created a ThreadLocal with key of type
[null] (value
[com.avaje.ebeaninternal.server.transaction.DefaultTransactionThreadLocal
$1@2f86780d]) and a value of type
[com.avaje.ebeaninternal.server.transaction.TransactionMap] (value
[com.avaje.ebeaninternal.server.transaction.TransactionMap@2533b5db])
but failed to remove it when the web application was stopped. To
prevent a memory leak, the ThreadLocal has been forcibly removed.
26-Mar-2011 12:59:03 org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: A web application created a ThreadLocal with key of type
[null] (value
[com.avaje.ebeaninternal.server.transaction.DefaultTransactionThreadLocal
$1@2f86780d]) and a value of type
[com.avaje.ebeaninternal.server.transaction.TransactionMap] (value
[com.avaje.ebeaninternal.server.transaction.TransactionMap@76d88b7b])
but failed to remove it when the web application was stopped. To
prevent a memory leak, the ThreadLocal has been forcibly removed.
26-Mar-2011 12:59:03 org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: A web application created a ThreadLocal with key of type
[null] (value
[com.avaje.ebeaninternal.server.transaction.DefaultTransactionThreadLocal
$1@2f86780d]) and a value of type
[com.avaje.ebeaninternal.server.transaction.TransactionMap] (value
[com.avaje.ebeaninternal.server.transaction.TransactionMap@49e926fd])
but failed to remove it when the web application was stopped. To
prevent a memory leak, the ThreadLocal has been forcibly removed.
26-Mar-2011 12:59:03 org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: A web application created a ThreadLocal with key of type
[null] (value
[com.avaje.ebeaninternal.server.transaction.DefaultTransactionThreadLocal
$1@2f86780d]) and a value of type
[com.avaje.ebeaninternal.server.transaction.TransactionMap] (value
[com.avaje.ebeaninternal.server.transaction.TransactionMap@5889dee2])
but failed to remove it when the web application was stopped. To
prevent a memory leak, the ThreadLocal has been forcibly removed.
26-Mar-2011 12:59:03 org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: A web application created a ThreadLocal with key of type
[null] (value
[com.avaje.ebeaninternal.server.transaction.DefaultTransactionThreadLocal
$1@2f86780d]) and a value of type
[com.avaje.ebeaninternal.server.transaction.TransactionMap] (value
[com.avaje.ebeaninternal.server.transaction.TransactionMap@12db71e4])
but failed to remove it when the web application was stopped. To
prevent a memory leak, the ThreadLocal has been forcibly removed.
26-Mar-2011 12:59:03 org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: A web application created a ThreadLocal with key of type
[null] (value
[com.avaje.ebeaninternal.server.transaction.DefaultTransactionThreadLocal
$1@2f86780d]) and a value of type
[com.avaje.ebeaninternal.server.transaction.TransactionMap] (value
[com.avaje.ebeaninternal.server.transaction.TransactionMap@6f76dd71])
but failed to remove it when the web application was stopped. To
prevent a memory leak, the ThreadLocal has been forcibly removed.
26-Mar-2011 12:59:03 org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: A web application created a ThreadLocal with key of type
[null] (value
[com.avaje.ebeaninternal.server.transaction.DefaultTransactionThreadLocal
$1@2f86780d]) and a value of type
[com.avaje.ebeaninternal.server.transaction.TransactionMap] (value
[com.avaje.ebeaninternal.server.transaction.TransactionMap@18317b1d])
but failed to remove it when the web application was stopped. To
prevent a memory leak, the ThreadLocal has been forcibly removed.
26-Mar-2011 12:59:03 org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: A web application created a ThreadLocal with key of type
[null] (value
[com.avaje.ebeaninternal.server.transaction.DefaultTransactionThreadLocal
$1@2f86780d]) and a value of type
[com.avaje.ebeaninternal.server.transaction.TransactionMap] (value
[com.avaje.ebeaninternal.server.transaction.TransactionMap@39e6258e])
but failed to remove it when the web application was stopped. To
prevent a memory leak, the ThreadLocal has been forcibly removed.
runScript



Cheers
Chris

Rob Bygrave

unread,
Mar 27, 2011, 5:53:31 PM3/27/11
to eb...@googlegroups.com, Chris

in web.xml you can register a listener: com.avaje.ebeaninternal.server.core.ServletContextListener

This will initiate the shutdown of the background threads etc when the servlet context is redeployed/shutdown (otherwise it relies on a JVM Shutdown hook).

Hmmm, need to look at the ThreadLocal's though. What version of Tomcat are you using?

Chris Burrell

unread,
Mar 28, 2011, 3:49:09 AM3/28/11
to Rob Bygrave, eb...@googlegroups.com
Version of Tomcat is a 6.x edition .I  believe it's the 6.0.24 off the top of my head. Will check and let you know if otherwise.

Cheers
Chris

Chris Burrell

unread,
Mar 28, 2011, 3:43:26 PM3/28/11
to Rob Bygrave, eb...@googlegroups.com
In fact I'm using 6.0.26

Chris

unread,
Mar 28, 2011, 4:27:07 PM3/28/11
to Ebean ORM
After using the shutdown listener (logs below). You can see H2 is
still up and running (is that something Ebean could shutdown? since it
would nicely abstract away the need for knowing it's H2 that's
running, as opposed to MySQL which couldn't be shutdown at all)

One scenario I have come across before is where SHUTDOWN is initiated.
And actually everything shuts down properly but not on time. For
example, in a situation where a thread is designed so:

class MyThread {
boolean active = true;

public void run() {
while(active) { doSomething(); sleep(10 seconds); }
}

public void shutdown() {
active = false;
}
}

In the case above it might be at least 9 seconds before the thread
actually dies.

Not sure if that's the case with Ebean, but thought I'd suggest it as
it looks like one Thread relies on a Timer mechanism and others are
two with "background" tasks (polling?)


INFO: ThreadPool [Ebean-db] Shutting down; threadCount[1] busyCount[0]

28-Mar-2011 21:01:42 org.apache.catalina.loader.WebappClassLoader
clearReferencesJdbc
SEVERE: A web application registered the JBDC driver [org.h2.Driver]
but failed to unregister it when the web application was stopped. To
prevent a memory leak, the JDBC Driver has been forcibly unregistered.
28-Mar-2011 21:01:42 org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: A web application appears to have started a thread named
[Ebean-db-periodic-1] but has failed to stop it. This is very likely
to create a memory leak.
28-Mar-2011 21:01:42 org.apache.catalina.loader.WebappClassLoader
clearReferencesStopTimerThread
SEVERE: A web application appears to have started a TimerThread named
[EbeanCacheWarmer] 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.
28-Mar-2011 21:01:42 org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads
SEVERE: A web application appears to have started a thread named
[Ebean-db-LuceneManager] but has failed to stop it. This is very
likely to create a memory leak.
28-Mar-2011 21:01:42 org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: A web application created a ThreadLocal with key of type
[null] (value [com.google.inject.internal.InjectorImpl$1@56f9659d])
and a value of type [java.lang.Object[]] (value
[[Ljava.lang.Object;@f7e5307]) but failed to remove it when the web
application was stopped. To prevent a memory leak, the ThreadLocal has
been forcibly removed.
28-Mar-2011 21:01:42 org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: A web application created a ThreadLocal with key of type
[null] (value
[com.avaje.ebeaninternal.server.transaction.DefaultTransactionThreadLocal
$1@2e7cf883]) and a value of type
[com.avaje.ebeaninternal.server.transaction.TransactionMap] (value
[com.avaje.ebeaninternal.server.transaction.TransactionMap@e9f784d])
but failed to remove it when the web application was stopped. To
prevent a memory leak, the ThreadLocal has been forcibly removed.


On Mar 28, 8:43 pm, Chris Burrell <christopher.burr...@gmail.com>
wrote:
> In fact I'm using 6.0.26
>
> On 28 March 2011 08:49, Chris Burrell <christopher.burr...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Version of Tomcat is a 6.x edition .I  believe it's the 6.0.24 off the top
> > of my head. Will check and let you know if otherwise.
>
> > Cheers
> > Chris
>
> > On 27 March 2011 22:53, Rob Bygrave <robin.bygr...@gmail.com> wrote:
>
> >> in web.xml you can register a
> >> listener: com.avaje.ebeaninternal.server.core.ServletContextListener
>
> >> This will initiate the shutdown of the background threads etc when the
> >> servlet context is redeployed/shutdown (otherwise it relies on a JVM
> >> Shutdown hook).
>
> >> Hmmm, need to look at the ThreadLocal's though. What version of Tomcat are
> >> you using?
>
Reply all
Reply to author
Forward
0 new messages