#11757 closed bug (fixed)
IE 8 memory accumulation in iframes with jQuery 1.7.2
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | low | Milestone: | 1.8 |
Component: | support | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
jQuery content in iframe isn't cleared if you leave the iframe in IE 8. Here is a simple example.
top.htm <!DOCTYPE html> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=8"/> </head> <body> <a href="about:blank">about:blank</a><br/> <iframe src="iframe.htm"></iframe> </body> </html> iframe.htm <!DOCTYPE html> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=8"/> <script src="jquery.js" type="text/javascript"></script> </head> <body> <a href="iframe.htm">iframe</a> </body> </html>
Click link in iframe to repeatedly "leak" memory in IE 8. Then click the about:blank link to see memory levels EVENTUALLY return (doesn't return right away unless, oddly, you add a reference to jquery.js in the top page as well).
To fix the leak, make this modification to the jquery.js file. Add the two lines and modify the attachEvent call as noted.
jQuery.support = (function() { … var onclicktmp = null; // adamki - added if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { div.attachEvent( "onclick", onclicktmp = function() { // adamki - added the assignment to onclicktmp // Cloning a node shouldn't copy over any // bound event handlers (IE does this) support.noCloneEvent = false; }); div.cloneNode( true ).fireEvent( "onclick" ); div.detachEvent( "onclick", onclicktmp); // adamki added }
I made the change because I noticed the event handler was never removed from the div.
Change History (8)
comment:1 Changed 11 years ago by
Component: | unfiled → support |
---|---|
Priority: | undecided → low |
Status: | new → open |
comment:2 Changed 11 years ago by
Our software team also discovered that this memory leak exists in ie 6.0 and 7.0. Downgrading the version of Jquery to 1.7.1 resolved the memory leak issue. On some pages we were loosing up to 1.5 megs per page refresh.
comment:3 Changed 11 years ago by
Wow! This was causing huge memory leaks for us! We have iframes imbedded 3 layers deep (multiple iframes in iframes) and was causing 100mb memory jumps each time a page was loaded, this is a very important issue for us, I hope there is a fix soon.
comment:4 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | open → closed |
Fix #11757. IE 6/7 can't clean up circular DOM-JS refs.
Why? Because it's dumb. Verified with the case in the ticket.
Changeset: ad8dc12ac28915891127666d5b6c2d3200d1e79c
comment:5 Changed 11 years ago by
Milestone: | None → 1.8 |
---|
comment:6 Changed 11 years ago by
comment:8 Changed 10 years ago by
I still have leaks with IE 8 and the same testcase. Tested with versions 1.8.2 and 1.10+.
Confirmed. The memory grows about 500kb on each click.
Live testcase: http://wroug.com/stuff/testcases/iframe-memleak-ie8/
Live testcase without jQuery: http://wroug.com/stuff/testcases/iframe-memleak-ie8/index-without-jquery.html