Am I correct in assuming that when an element is detached, i.e, its detached() method for Polymer 1.+ or disconnectedCallback() for Polymer 2.+ runs, all references to that element and its childs are removed and no memory leak can be associated with that element anymore?
No, detached
/disconnectedCallback
are invoked when the element is removed from the document, but it does not indicate that there are no references to the element.
For example, a Polymer element could call setInterval()
with a callback that holds a reference to one of its properties. Removing that element from the document (e.g., via Node.removeChild()
) does not automatically stop the timer, so it's possible for the element to remain in memory after no longer being in the document. clearInterval()
should be called in order to avoid this.
Also note JavaScript currently has no garbage collection semantics. [1]