Issue 630 in google-guice: Guice + Tomcat potential memory leak

49 views
Skip to first unread message

google...@googlecode.com

unread,
May 17, 2011, 12:39:34 PM5/17/11
to google-g...@googlegroups.com
Status: New
Owner: ----

New issue 630 by pas256: Guice + Tomcat potential memory leak
http://code.google.com/p/google-guice/issues/detail?id=630

I have just started using Google Guice with my Tomcat webapp, and have
noticed the following in the catalina.out file whenever the WAR file is
undeployed:

----
May 16, 2011 5:37:24 PM org.apache.catalina.startup.HostConfig
checkResources INFO: Undeploying context [/app]

May 16, 2011 5:37:24 PM org.apache.catalina.loader.WebappClassLoader
clearReferencesThreads SEVERE: A web application appears to have started a
thread named [com.google.inject.internal.util.$Finalizer] but has failed to
stop it. This is very likely to create a memory leak.

May 16, 2011 5:37:24 PM 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@10ace8d]) and a value of type
[java.lang.Object[]] (value [[Ljava.lang.Object;@7e9bed]) but failed to
remove it when the web application was stopped. To prevent a memory leak,
the ThreadLocal has been forcibly removed.
----

I am not sure what causes this, or how I can stop it from happening.

I have only followed the instructions from here:

http://code.google.com/docreader/#p=google-guice&s=google-guice&t=ServletModule

... and haven't done anything fancy with it yet. I just have 2 servlets and
a filter.

This issue is also posted on StackOverflow:
http://stackoverflow.com/questions/6025089/guice-tomcat-potential-memory-leak

google...@googlecode.com

unread,
May 17, 2011, 12:49:46 PM5/17/11
to google-g...@googlegroups.com

Comment #1 on issue 630 by cgdec...@gmail.com: Guice + Tomcat potential
memory leak
http://code.google.com/p/google-guice/issues/detail?id=630

See issue 288.

google...@googlecode.com

unread,
May 17, 2011, 1:07:06 PM5/17/11
to google-g...@googlegroups.com
Updates:
Status: Invalid

Comment #2 on issue 630 by sberlin: Guice + Tomcat potential memory leak
http://code.google.com/p/google-guice/issues/detail?id=630

(No comment was entered for this change.)

google...@googlecode.com

unread,
Nov 10, 2011, 1:33:44 PM11/10/11
to google-g...@googlegroups.com

Comment #3 on issue 630 by tj.rothw...@gmail.com: Guice + Tomcat potential
memory leak
http://code.google.com/p/google-guice/issues/detail?id=630

+sberlin, Could you help me understand why this is invalid?

It appears that InjectorImpl creates a ThreadLocal. Could GuiceFilter or
GuiceServletContextListener be used to clean it up?

google...@googlecode.com

unread,
Nov 10, 2011, 2:04:15 PM11/10/11
to google-g...@googlegroups.com

Comment #4 on issue 630 by pas...@gmail.com: Guice + Tomcat potential
memory leak
http://code.google.com/p/google-guice/issues/detail?id=630

Yeah, I don't understand what is happening in Issue 288, but I guess it's
related.

I think he meant Duplicate not Invalid.

It was also meant to be fixed in version 2.0... version 3.0 is out and
still not fixed so go figure. Fingers crossed for 3.1

google...@googlecode.com

unread,
Nov 10, 2011, 2:29:46 PM11/10/11
to google-g...@googlegroups.com
Updates:
Status: Duplicate
Mergedinto: 288

Comment #6 on issue 630 by mccu...@gmail.com: Guice + Tomcat potential
memory leak
http://code.google.com/p/google-guice/issues/detail?id=630

Issue 288 (the background finalizer thread) will be fixed when the Guava
dependency is upgraded to r10+

The ThreadLocal reported by Tomcat is separate - this is actually a simple
Object array of length 1 which is used to manage contexts during injection.
The array element is guaranteed to be null outside of any call to the
injector so it won't cause any leak. The ThreadLocal will be reclaimed
after the injector is no longer referenced. However it may appear to stay
around for longer if you use reflection to peek into the ThreadLocal map
like Tomcat does, due to the current JDK ThreadLocal implementation.

google...@googlecode.com

unread,
Nov 10, 2011, 2:33:53 PM11/10/11
to google-g...@googlegroups.com

Comment #7 on issue 630 by pas...@gmail.com: Guice + Tomcat potential
memory leak
http://code.google.com/p/google-guice/issues/detail?id=630

Ah thanks for the details.


google...@googlecode.com

unread,
Jan 14, 2013, 9:09:34 AM1/14/13
to google-g...@googlegroups.com

Comment #8 on issue 630 by lauri.le...@gmail.com: Guice + Tomcat potential
memory leak
http://code.google.com/p/google-guice/issues/detail?id=630

Our Tomcat also complains about this.

Because of this shortcoming in Guice, we cannot use Tomcat Manager to
re-deploy our software. If we would use Manager, we would eventually run
out of PermGen space.

google...@googlecode.com

unread,
Apr 17, 2015, 12:14:07 PM4/17/15
to google-g...@googlegroups.com

Comment #9 on issue 630 by aglyn...@gmail.com: Guice + Tomcat potential
memory leak
https://code.google.com/p/google-guice/issues/detail?id=630

Why would using Tomcat manager make any difference to it leaking permgen
space? I have an app that is running into the permgen issue because it is
using a guava singleton for the UserInfo object and associated caches, but
it makes no difference whether I deploy it manually or through Tomcat
manager, and I can't see how it would.

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
Reply all
Reply to author
Forward
0 new messages