The leak is classic: introduce a dynamic script DOM element, let the script execute, then remove the DOM node. Rinse. Repeat. The problem is the DOM element will not free and I cannot see any circular reference. I've tried all the tricks and can't solve it. The leak exists in both ie 6-8 and firefox.
My kit does real time updates without requiring a page reload/refresh so the leak is bothersome and can grow quickly.
I have tried moving the node to a garbage pool DIV and setting the innerHTML to "". I have tried the destroy() approach. I have stood on my head and walked with my ears.
All you need are these two small files:
File 1 leak.js:
// all the file contains is this one comment line!
File 2 leak.html:
<html>
<SPAN id='leakid'><SCRIPT language='JavaScript'>
// CALLED EVERY 500 ms FROM TIMER
function getUpdate() {
var mySpan = document.getElementById('leakid');
// WHACK THE OLD ONE FROM LAST GO AROUND
var oldNode = document.getElementById('myUpdater');
if (oldNode) {
oldNode.parentNode.removeChild(oldNode);
oldNode = null;
}
// LOAD A NEW ONE
var newNode = document.createElement('script');
newNode.type = 'text/javascript';
newNode.src = 'leak.js';
newNode.id = 'myUpdater';
mySpan.appendChild(newNode);
newNode = null;
mySpan = null;
return;
}
</SCRIPT></SPAN>
<BODY bgcolor="#4682B4" leftmargin="2" marginheight="0" marginwidth="0" topmargin="2" onload="getUpdate(); timerInterval = setInterval('getUpdate()', 500);">
</BODY></HTML>