Reputation: 432
Does calling .remove() on a ConcurrentHashMap object open that object to be garbage collected? The Javadocs say a lot about removing the mapping but never mentions what happens to the object.
I'm having a bit of a memory leak somewhere and I'm wondering if this might be it. Should I nullify objects in my hashmap before removing?
Upvotes: 1
Views: 509
Reputation: 2272
Removes a single instance of the specified element from this collection, if it is present (optional operation). More formally, removes an element e such that
(o==null ? e==null : o.equals(e)),
if the collection contains one or more such elements.
so as e==null
it becomes eligible for GC, We do not achieve anything by Nullifying it ever in java.
Upvotes: 1