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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

/#!/JoePea
I have a `WeakMap` whose values are `Map` instances. The values of all
the `Map`s inside the `WeakMap` are `object`s. If references to keys
of the `WeakMap` are lost and therefore those items removed from the
`WeakMap`, will the `Map`s' 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 `Map`s manually first.

/#!/JoePea
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

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

Jordan Harband
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.

On Tue, Oct 24, 2017 at 11:20 AM, /#!/JoePea <[hidden email]> wrote:
I have a `WeakMap` whose values are `Map` instances. The values of all
the `Map`s inside the `WeakMap` are `object`s. If references to keys
of the `WeakMap` are lost and therefore those items removed from the
`WeakMap`, will the `Map`s' 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 `Map`s manually first.

/#!/JoePea
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss