Robert Schuster wrote:
Hi,


Unfortunately I don't think this is the correct solution.  In practice
I think this patch would not cause caching for very long -- the next
GC cycle would notice that there are no other references to the keys
in the map, and it would be cleared.


One idea would be a map where the entries are soft references, so that
(in theory) they are only cleared when memory is needed

OK, I thought WeakHashMap would work this way.


(though at
least libgcj treats soft references like weak ones atm).  Or, we could
have a fixed size cache that removes the least-recently-used entry.

We have so many VM with so many different runtime parameters. I am in favor of
implementing a SoftHashMap to let the GC decide when to clean out unused 
references.


The problem (as Tom pointed out) with this is that for many VMs (like libgcj) there is no difference between Soft and Weak references. So the end effect is that your approach would do very little caching. A limited size cache using LRU purging and hard references on the other hand would work well.

David Daney.


_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to