With addressing your concerns about the Bpage reference, soft references make for a much less reliable memory management scheme.  I would only use a weak reference cache.  The capacity of the hard reference cache fronting for the weak reference cache then sets the retention capacity for the objects.

From: Dan Gravell <gravelld2@users.sf.net>
Reply-To: "[jdbm:discussion]" <12570@discussion.jdbm.p.re.sf.net>
Date: Wednesday, January 15, 2014 7:09 AM
To: "[jdbm:discussion]" <12570@discussion.jdbm.p.re.sf.net>
Subject: [jdbm:discussion] SoftCache not garbage collecting

I experienced an OOME with my app so I opened up the heap dump in MAT. Amongst other things I noticed the SoftCache running at much higher memory consumption than expected, with thousands of SoftCache$Entry instances. I would expect all soft references that pass the normal heuristics (no strong references to the referent) to be GC'd so I was surprised to see these still there.

Looking inside the SoftCache$Entrys I noticed that the referent, a BPage, is also the _ser attribute. This must stop the referent being garbage collected. Is this expected behaviour? If so, how does the SoftCache ever have its entries GC'd?

It's all the more confusing because when I look at the code I can only see one path to create an Entry, and that sets the _ser as null! That is, via SoftCache.get:250 -> SoftCache.put(key, value, false, null).

SoftCache not garbage collecting

Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/jdbm/discussion/12570/

To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/