tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DO NOT REPLY [Bug 44389] Cleanup of org.apache.naming.resources. CacheEntry resources (memory leak)
Date Tue, 04 Mar 2008 13:26:17 GMT

--- Comment #1 from Arto Huusko <>  2008-03-04 05:26:16 ---
Caused by non-static inner class DispatchData in
org.apache.cataline.core.ApplicationContext being held in a (non-static)

While seemingly dispatchData is GC'able, Sun JVM Thread class holds reference
to the ThreadLocal object through Thread class. Example path (from jhat):

--> java.lang.ThreadGroup@0x2aa4b85608 (67 bytes)  (field threads:)
--> [Ljava.lang.Thread;@0x2aa674dda0 (272 bytes) (Element 21 of
--> java.lang.Thread@0x2aa6f4b418 (164 bytes) (field threadLocals:)
--> java.lang.ThreadLocal$ThreadLocalMap@0x2aa6f86d18 (32 bytes) (field table:)
--> [Ljava.lang.ThreadLocal$ThreadLocalMap$Entry;@0x2aa6f86d38 (528 bytes)
(Element 16 of [Ljava.lang.ThreadLocal$ThreadLocalMap$Entry;@0x2aa6f86d38:)
--> java.lang.ThreadLocal$ThreadLocalMap$Entry@0x2aa6f87408 (56 bytes) (field
--> org.apache.catalina.core.ApplicationContext$DispatchData@0x2aa6f87440 (40
bytes) (field this$0:)
--> org.apache.catalina.core.ApplicationContext@0x2aa6f87b88 (72 bytes)

Because dispatchData field is non-static, what ever it contains is leaked when
a particular ApplicationContext is discarded: a new ThreadLocal object is
created for each ApplicationContext instance in each Thread, and when the
instance is discarded, an unaccessible but still not GC'able reference stays in
the JVM's Thread instances that used it.

Because DispatchData inner class is not static, it also causes a reference to
the ApplicationContext instance itself, which leads to catastrophic results, if
the ClassLoader of the web app is referencable throught the ApplicationContext.

Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message