commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Juozas Baliuka" <>
Subject Re: [collections] SoftRefHashMap (was RE: Avalon excalibur collections migration status)
Date Wed, 17 Jul 2002 06:11:49 GMT

> And I think it was determined that there's
> no way to fix purge() to be efficient without breaking backwards
> compatibility.
yes, "protected Reference createReference( Object referent ) " is more
problematic for

backwards compatibility, but I think this method can not be used in new

"purge()"  can do nothing (some new private method for cleanup), and both
can be depricated, I believe this will not break backwards  compatibility.

> And a map with weak references is quite different from
> a map with soft references.  A weak reference is cleared as soon as
> its referent becomes weakly reachable.  A soft reference is cleared
> at the discretion of the garbage collector in response to memory
> demand.  A WeakMap would be used to associate things with a
> particular object only as long as that object lived; a SoftMap would
> be used to create a cache that would be emptied in response to memory
> demand.  Different animals.
Very possible I understand WeakReference wrong, but as I understand GC
clears it, and GC runs then memory is low (possible it is not true), of
course reachability is weaker. If it is true, both reference types are
almost the same for cache.

> I like the MRU idea but I'm unsure how best to implement it.
> -Paul

I use array to hold strong references on values, it needs constant time
to manage reachability, "put" and "get" calls this method for "value":
private void addStrongRef(Object object) {

if (m_strongRefs != null) {

m_strongRefs[(m_current++) % m_maxStrongRefCount] = object;



May be it is possible to find a better solution.

> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message