Java / Map and its implementations
What are the different Reference types available in Java?
The different available reference types are WeakReference and softReference (PhantomReference).
These reference types are defined in java.lang.ref package and provided to assist Java Garbage Collector in a case of low memory issues. If you wrap an object with WeakReference then it will be eligible for garbage collected if there are no strong reference. They can later be reclaimed by Garbage collector if JVM is running low on memory.
The java.util.WeakHashMap is a special Map implementation, whose keys are the object of WeakReference, so if only Map contains the reference of any object and no other, those object can be garbage collected if GC needs memory.
More Related questions...