commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jack, Paul" <pj...@sfaf.org>
Subject RE: [Collections][SUBMIT] ReferenceMap...take 3...
Date Fri, 19 Jul 2002 16:59:05 GMT
> Is there a compelling reason why the autoPurge method uses 
> the internal structure of the Map?  It looks like it could 
> just synchronize properly and call purge(); thus it could 
> be implemented in MapUtils as a decorator.

A map created by autoPurge removes mappings as soon as 
the garbage collector enqueues the References; the mappings
are removed as soon as possible.  To do so it requires 
access to the internal ReferenceQueue.

The method you describe would require the background thread 
to wake up periodically and call purge(), which would mean 
some extra lag time.

 
> How is the hashing performance?  It looks like you're going 
> to run into the problems discussed previously on this list, 
> where most objects that  don't customize their hashCode method 
> will hash to the same buckets.  That is, if the hashCode is just 
> some memory address (e.g. a multiple of 8), you'll hash all the 
> objects into the same (tablesize/8) buckets.

Well, I just copied the algorithms from java.util.WeakHashMap,
so there really wasn't much thought put into the hash function.

What algorithm would you suggest?

-Paul

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message