@nimakro I'm guessing a regular map of weakreferences won't have it's key-value pair garbage collected when it's no longer referenced. It will keep the pairs, maybe pointing to nulls. Might be wrong though.
n
nimakro
08/17/2017, 5:23 PM
@pim Is that not just true if the key is not referenced anymore. If the value is garbage collected there are still nulls in the weakHashMap?
p
pim
08/17/2017, 5:25 PM
I have no experience with weak references, sorry 🙂
pim
08/17/2017, 5:26 PM
I'd think that if the value is GC, the key gets removed as well
pim
08/17/2017, 5:27 PM
"Storing only weak references allows a key-value pair to be garbage-collected when its key is no longer referenced outside of the WeakHashMap." Nevermind
👍 1
n
nimakro
08/17/2017, 5:29 PM
Yes that's what I thought and that's why I can't figure out what the benefit is of using the WeakHashMap since the keys are Strings
p
pim
08/17/2017, 5:50 PM
But are these strings referenced somewhere? Otherwise they would be GCd immediately