[concurrency-interest] ConcurrentReferenceMap enhancement to 166 - Feedback Requested
Jason T. Greene
jason.greene at redhat.com
Fri May 2 20:41:21 EDT 2008
Bob Lee wrote:
> Sorry for the delayed response...
>
> On Thu, Apr 17, 2008 at 11:28 AM, Tom Hawtin <Thomas.Hawtin at sun.com
> <mailto:Thomas.Hawtin at sun.com>> wrote:
>
> Standard equality doesn't make sense for weak/soft. Weak/soft
> references are fundamentally identity based.
>
>
> Weak certainly. But for soft?
>
>
> I've been thinking about this, and I think it's perhaps even more true
> for soft references. Presumably you're using a soft reference because
> you want to save memory--why waste memory with two equivalent copies of
> the same piece of data?
IMO, the typical case of a soft-key map is a simple cache, where you
want the table entry (combined space consumed by the key and value) to
stay around for as long as possible, until the VM actually needs the space.
Code that uses this cache, might not have the instance of the key
available to it, especially if the key data is read from some other
source (perhaps over i/o). While the construction of a duplicate key
object from that data is consuming extra memory, its lifespan is most
likely much shorter (it might only exist for a single operation).
--
Jason T. Greene
JBoss, a division of Red Hat
More information about the Concurrency-interest
mailing list