Are Map with no references and their values with no references GC'd?

# /#!/JoePea (4 months ago)

I have a WeakMap whose values are Map instances. The values of all the Maps inside the WeakMap are objects. If references to keys of the WeakMap are lost and therefore those items removed from the WeakMap, will the Maps' values be GC'd if there are no references to the Maps or to the Map values.

I'm intuitively assuming "yes", but just want to confirm that I don't have to explicitly removed everything from the Maps manually first.


# Jordan Harband (4 months ago)

If the Map is collected, all of its keys and values are no longer referenced by it, so if there were no other references to them, they'd be collected at some point.