Memory leak in html() function
Greetings from Australia.
re: code snippet below...
I do not understand why function aa() still exists at (line-Z). After $('#d3').html() is loaded into #d1 at (line-Y), why does JQuery NOT free memory consumed by aa() ? What are the consequences of calling Control.init() 200 times ?
Thanks in advance
Ron B
var Control = {
init : function() {
alert(typeof aa); // (line-X) aa() is undefined (due to it being commented out)
var s = $('#d2').html().replace(/\/\//g, ""); // comments are removed making aa() valid js
$('#d1').html(s);
aa();
s = $('#d3').html();
$('#d1').html(s); // (line-Y)
bb();
alert(typeof aa); // (line-Z) aa() should be undefined as it was overwritten by bb()
}
}
</script>
</head>
<body>
<div id="d1"></div>
<div id="d2">
<script type='text/javascript'>
//function aa() {
// alert('aa');
//}
</script>
</div>
<div id="d3">
<script type='text/javascript'>
function bb() {
alert('bb');
}
</script>
</div>
</body>