Trying to examine intricacies of JavaScript GC, I got deep into the weeds (that is, into the ECMAScript spec). It was found by me that an object should not be collected as long as it is deemed “live”. And liveness itself is defined as follows: At any point during evaluation, a set of objects S is considered live if either
Tag: weak-references
Lookup table with weak references in Javascript
I have a tree structure with elements dynamically added and removed. The elements are loaded dynamically from the network. What I want to achieve is to have a lookup table that maps the element’s id to the actual element in the tree. Now, the problem when using a simple Map or Object is that it holds strong references to the