Hi,

implementing benchmarks for BU2 has shown, that the WeakHashMap with
WeakReferences to the values is not sufficient for caching [1]. The
solution I suggested for that issue is not to use WeakReferences as values.
This will prevent NPEs if the GC kicks in.
But it only resolves part of the problem. WeakHashMap itself does not seem
to be the best choice for caching. The problem is, that it uses
WeakReferences for it's keys. So the  GC will clean up entries, if no
strong reference to a key can be found. This certainly isn't what we want.
Someone has suggested to use a LRUMap implementation like the one in
o.a.collections [2].
How do you feel about that?
If we what to use the LRUMap implementation of collections, how would we do
that? We con't want to depend on other components, so do we have to copy
the code to the BU2 code base?

Regards,
Benedikt

PS: this all applies to BeanUtils1 as well, because we adopted the caching
from there.

[1] https://issues.apache.org/jira/browse/SANDBOX-433
[2]
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/LRUMap.java?view=markup

Reply via email to