I know there is a WeakHashMap in java.util, but since it uses WeakReferences for everything, which is only referenced by this Map, referenced objects will get lost on the next GC cycle. So it's nearly useless if you want to cache random data, which is very likely to be requested again without being Hard-linked the rest of the time. The b...
Is there softreference-based LinkedHashMap in Java? If no, has anyone got a snippet of code that I can probably reuse? I promise to reference it correctly.
Thanks.
...
I need to cache objects in Java using a proportion of whatever RAM is available. I'm aware that others have asked this question, but none of the responses meet my requirements.
My requirements are:
Simple and lightweight
Not dramatically slower than a plain HashMap
Use LRU, or some deletion policy that approximates LRU
I tried Link...
Can someone explain the difference between the three Reference classes (or post a link to a nice explanation)? SoftReference > WeakReference > PhantomReference, but when would I use each one? Why is there a WeakHashMap but no SoftHashMap or PhantomHashMap?
And if I use the following code...
WeakReference<String> ref = new WeakReference...
Possible Duplicate:
Why doesn't .NET have a SoftReference as well as a WeakReference, like Java?
Java has several types of references, two of these are Weak and Soft. I know that .NET has Weak references but does it have Soft ones too?
(Soft references are stronger than Weak ones in that they will try to keep an object alive...