Сборка мусора в JavaScript-замыканиях
Мне нужна помощь, чтобы понять, как это работает (или нет).
In a web page, I create a click event listener for a node. Within the listener, I create an instance of some random class, which sets the node as property within itself. So, ifvar classInstance
is the instance, I can access the node as something like classInstance.rootNode
.
When the listener fires, I setup an ajax request, keep classInstance
in closure and pass along the ajax response to classInstance
and use it to perhaps modify the rootNode
's style or content or whatever.
У меня вопрос, как только я закончу сclassInstance
Если предположить, что ничто иное не ссылается на него и само по себе оно не содержит ничего другого в своем закрытии, избавится ли от него сборщик мусора? Если нет, то как мне пометить его для утилизации?