IE Memory Leak in ajax getScript() calls
Hello,
I've found and fixed a small memory leak in the jQuery 1.2.6 codebase
that pertains to the getScript ajax methods. (around line 2670 in
jQuery 1.2.6)
the new code is as follows - I added
script.onload = script.onreadystatechange = null;
right before the head.removeChild( script ); call to help IE collect
its garbage.
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function(){
if ( !done && (!this.readyState ||
this.readyState == "loaded" || this.readyState == "complete") ) {
done = true;
success();
complete();
// handle memory leak in IE
script.onload = script.onreadystatechange = null;
head.removeChild( script );
}
};
This issue becomes very apparent if you use $.getScript() to load a
lot of scripts in a effort to bypass the blocking nature of script
loads in browsers. Multiple page loads will leak memory each time
eventually bringing IE to a crawl...
I'd love your feedback on this.
Thanks,
Roger
Sr Web Developer - ESPN