We’re running a small JRuby on Rails app under Tomcat 6.0.28 with a
Spring-based backend. I’ve spent some time with the Eclipse Memory
Analysis tool and I can definitely tell that instances of
theJRubyClassLoader are leaking. The total number of classes loaded
(and therefore PermGen usage) goes up every time I deploy. More
importantly, we’re seeing this on our production sites with virtually
every incoming request. (See
for my original question on StackOverflow).
I setup our webapp to on my localhost to only use a single JRuby
runtime and then I effectively did a hot-deploy to Tomcat by touching
the war. After doing that a few times, I can see several instances of
the JRubyClassLoader sitting around.
Since the classloader isn’t getting released, the classes it loaded
aren’t getting released and we’re running out of PermGen space.
Using Eclipse Memory Analysis, I can see the path to the GC root looks
like:
org.jruby.util.JRubyClassLoader
jrubyClassLoader org.jruby.Ruby
runtime org.jruby.util.io.ChannelStream
reference java.lang.ref.Finalizer
next java.lang.ref.Finalizer
And the list of next java.lang.ref.Finalizer goes on seemingly
forever… to point where I can’t seem to find the actual GC root.
If run the Leak Suspects report, the #1 suspect is
“java.lang.ref.Finalizer”, loaded by “”.
Any ideas why the Finalizer is sticking around?
As a possibly related side note, every time I do a hot deploy, a get a
slew of NullPointerExceptions:
java.lang.NullPointerException
at com.kenai.jffi.Function.finalize(Function.java:177)
at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
at java.lang.ref.Finalizer.access$100(Finalizer.java:14)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)
And I’m also seeing some errors with ThreadLocals which I suspect are
also related:
SEVERE: A web application created a ThreadLocal with key of type
[null] (value [com.kenai.jaffl.provider.StringIO$1@799a7266]) and a
value of type [java.lang.ref.SoftReference] (value
[java.lang.ref.SoftReference@accc4e9]) but failed to remove it when
the web application was stopped. To prevent a memory leak, the
ThreadLocal has been forcibly removed.
Jul 20, 2010 8:17:43 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: A web application created a ThreadLocal with key of type
[null] (value [org.joni.StackMachine$1@993a289]) and a value of type
[java.lang.ref.WeakReference] (value
[java.lang.ref.WeakReference@3b93d548]) but failed to remove it when
the web application was stopped. To prevent a memory leak, the
ThreadLocal has been forcibly removed.
Jul 20, 2010 8:17:43 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: A web application created a ThreadLocal with key of type
[null] (value [com.kenai.jaffl.provider.StringIO$1@799a7266]) and a
value of type [java.lang.ref.SoftReference] (value
[java.lang.ref.SoftReference@66978886]) but failed to remove it when
the web application was stopped. To prevent a memory leak, the
ThreadLocal has been forcibly removed.
Jul 20, 2010 8:17:43 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: A web application created a ThreadLocal with key of type
[null] (value [org.joni.StackMachine$1@993a289]) and a value of type
[java.lang.ref.WeakReference] (value
[java.lang.ref.WeakReference@66844a08]) but failed to remove it when
the web application was stopped. To prevent a memory leak, the
ThreadLocal has been forcibly removed.
Jul 20, 2010 8:17:43 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: A web application created a ThreadLocal with key of type
[org.springframework.core.NamedThreadLocal] (value [Name of currently
proxied bean]) and a value of type [java.lang.String] (value
[httpConnectionManagerParams]) but failed to remove it when the web
application was stopped. To prevent a memory leak, the ThreadLocal has
been forcibly removed.
Jul 20, 2010 8:17:43 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: A web application created a ThreadLocal with key of type
[null] (value [com.kenai.jaffl.provider.StringIO$1@799a7266]) and a
value of type [java.lang.ref.SoftReference] (value
[java.lang.ref.SoftReference@771887cc]) but failed to remove it when
the web application was stopped. To prevent a memory leak, the
ThreadLocal has been forcibly removed.
Jul 20, 2010 8:17:43 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
SEVERE: A web application created a ThreadLocal with key of type
[null] (value [org.joni.StackMachine$1@993a289]) and a value of type
[java.lang.ref.WeakReference] (value
[java.lang.ref.WeakReference@6b7b9f29]) but failed to remove it when
the web application was stopped. To prevent a memory leak, the
ThreadLocal has been forcibly removed.
Jul 20, 2010 8:17:43 AM org.apache.catalina.loader.WebappClassLoader
clearThreadLocalMap
All of the initial research was done using JRuby 1.5.0, but I’m seeing
the same results with 1.5.1 despite my hope that the resolution to
JRUBY-4838 would have solved my problems.
Any thoughts or suggestions?
-Sean
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email