Troublesome reflection-cached SoftReferences
Charles Oliver Nutter
charles.nutter at Sun.COM
Fri Apr 24 01:48:48 PDT 2009
I've run into a case in JRuby where a reflected method is keeping alive
a class, and that class references a large graph of JRuby objects. The
reflected method is off an anonymous interface implementation we create
at runtime. In order for that implementation to construct additional
Ruby objects, it has to reference an instance of our org.jruby.Ruby
class, which in turn references all globally-scoped data, and basically
keeps a lot of stuff alive.
The SoftReference appears to be part of the root set, and holds only an
array of Constructor objects. Given a bit of time, this reference is
cleared and the graph goes with it. But doing repeated redeploys of a
JRuby application can fill up the heap before those soft references get
a chance to clear.
So my questions:
* Is there any way to force the internal reflection caches to flush
themselves? It's very inconvenient that the cache is keeping alive a
class that should be dead.
* Is there any way to force an early SoftReference cleanup, before their
time has expired?
* Does anyone else find this caching behavior irritating?
- Charlie
More information about the hotspot-gc-use
mailing list