Troublesome reflection-cached SoftReferences

Charles Oliver Nutter charles.nutter at sun.com
Fri Apr 24 09:04:03 PDT 2009


Peter B. Kessler wrote:
> If you can get to the SoftReference objects, you can call 
> java.lang.ref.Reference.clear() on them.  That way they won't hold on to 
> their referent until the SoftReference policy clears them.
> 
> I'm with Ramki though: all the SoftReferences should be cleared by the 
> collector before it throws OOME at you.

Yeah, these seem to be some SoftReference out of my control, holding on 
to arrays of Method and Constructor and Field. I assume it's part of 
some caching for java.lang.reflect, but since they show up as being in 
the root set there's no parent to trace back to...

And yeah, I don't understand why these wouldn't be getting cleaned up 
either. The object immediately under the SoftReference, e.g. the array 
of Constructor[], does not appear to have any other parents in the heap 
dump. I can't figure out why it doesn't go away.

- Charlie



More information about the hotspot-gc-use mailing list