Dangers of using WeakReference/SoftReference in Hash-based collections

1 · Chris Banes · Dec. 20, 2011, midnight
Hey everyone, Just a quick post about something I saw this morning. In FriendCaster we use a HashMap collection of SoftReference’d Bitmap’s as an in-memory cache for images. This works fairly well as it means that we can get access to the bitmaps from memory (if they’re still in there). While looking through the source for Reference (super class of WeakReference and SoftReference) I saw that it does not override equals or......