My situation is this, I created instance of class at local scope, this instance during construction time assign one of method with binded context as event handler.
Minimal example:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Minimal</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
</head>
<body>
<a>Hello</a>
<button>Click</button>
<script text="javascript">
(function()
{
class App
{
constructor()
{
let anchor = document.getElementsByTagName(`a`)[0];
let anchorHandler = this.sayClicked.bind(this);
anchor.addEventListener(`click`, anchorHandler, false);
}
sayClicked()
{
alert(`Clicked`);
}
}
new App();
})();
</script>
</body>
</html>
I understand that after IIFE execution only reference to App instance is event handler with binded context. So far so good Chrome memory tab shows me
My issue is, after anchor element removal(remove was realized via console, console was erased), Chrome memory still shows me App instance at the memory. I don't understand it, I believe only reference was eventhandler, according this event handler should be removed also, which means only reference to App instance should be removed too, so I expected garbage collection. Before heap snapshot I forced garbage collection, but App instance is still there
Beside bound _this in native_bind() is window icon and Chrome tells me that it is reachable from window. I tried to examine window but I was not able to reach App instance.