Well, the javadoc is pretty clear about when SoftReference, WeakReference (and PhantomReference) ought to be garbage collected.
Yeah, not disagreeing with you here.
Surely you might use a regular Map with SoftReference values, instead of a SoftHashMap. The only thing you have to remember is not to use WeakHashMap for caching if you want to take advantage of the space on the heap as long as possible.
This is the bit I don't agree with. A SoftHashMap (has SoftReference keys) and a Map with SoftReference
values are completely different things. You're likely to keep strong references to the ID in all components that use the image - if the SoftReference was on the ID, it would never be GC'd before you ran out of memory. A WeakHashMap would be fine in the
specific scenario I mentioned, where when the ID has disappeared there's no way to get the image anyway.