I just came across this answer in SO where it is mentioned that the Google-collections MapMaker is awesome.I went through the documentation but couldn\'t really figure out w
It may help if you look at the descriptions of SoftReference and WeakReference.
SoftReference
is very useful for use in caches, as they will be specifically cleared when memory gets low.
WeakReference
tells the Garbage Collector that it can collect the object referenced to it as long as there are no strong references to it elsewhere. This is typically used with things that can be quickly looked up again as needed.
So, consider using MapMaker to create a ConcurrentMap with softValues for a cache, and one with weakKeys for temporary lookup tables.
Edit: softValues uses an LRU policy.