Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#11757 closed bug (fixed)

IE 8 memory accumulation in iframes with jQuery 1.7.2

Reported by: [email protected] Owned by:
Priority: low Milestone: 1.8
Component: support Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:


jQuery content in iframe isn't cleared if you leave the iframe in IE 8. Here is a simple example.

<!DOCTYPE html>
 <meta http-equiv="X-UA-Compatible" content="IE=8"/>
<a href="about:blank">about:blank</a><br/>
<iframe src="iframe.htm"></iframe>

<!DOCTYPE html>
 <meta http-equiv="X-UA-Compatible" content="IE=8"/>
 <script src="jquery.js" type="text/javascript"></script>
 <a href="iframe.htm">iframe</a>

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 9 years ago by sindresorhus

Component: unfiledsupport
Priority: undecidedlow
Status: newopen

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

comment:2 Changed 9 years ago by anonymous

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 9 years ago by anonymous

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 9 years ago by Dave Methvin

Resolution: fixed
Status: openclosed

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 9 years ago by dmethvin

Milestone: None1.8

comment:6 Changed 9 years ago by Pradeep

Can jquery confirm fix for #11757 is included in 1.8 ; JQuery Release 1.8B2 change log does not show #11757

comment:7 Changed 9 years ago by anonymous

I can find the same code on version 1.7.1

comment:8 Changed 8 years ago by quentin

I still have leaks with IE 8 and the same testcase. Tested with versions 1.8.2 and 1.10+.

Note: See TracTickets for help on using tickets.