Hi,
Douglas Crockford mentioned in a video on Yahoo! that before removing
an element it is a good idea to purge it's event handlers. I think he
was only refering to the event handlers defined inline in the HTML
element attributes. This purging is because the event handlers create
the circular memory leak in IE.
I am trying to create and observe this memory leak with with IE6 and
the example below. I can't see any memory leaking.
Is my test faulty or am I missing something else?
Thank you,
Peter
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Leak</title>
<script type="text/javascript">
function doLoad() {
for (var i=1000000;i--;) {
var p = document.createElement("p");
p.appendChild(document.createTextNode("clickme"));
p["onclick"]=(function(){return function(){alert("hi");};})();
document.body.appendChild(p);
document.body.removeChild(p);
}
}
</script>
</head>
<body onload="doLoad();">
</body>
</html>