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.