classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] RFC: Use WeakHashMap in java.util.ResourceBundle


From: David Daney
Subject: Re: [cp-patches] RFC: Use WeakHashMap in java.util.ResourceBundle
Date: Mon, 19 Sep 2005 16:11:45 -0700
User-agent: Mozilla Thunderbird 1.0.6-1.1.fc3 (X11/20050720)

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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]