Bug Tracker


Ticket #11757 (closed bug: fixed)

Opened 2 years ago

Last modified 6 months ago

IE 8 memory accumulation in iframes with jQuery 1.7.2

Reported by: adamki@… Owned by:
Priority: low Milestone: 1.8
Component: support Version: 1.7.2
Keywords: Cc:
Blocking: Blocked by:


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

comment:1 Changed 2 years ago by sindresorhus

  • Priority changed from undecided to low
  • Status changed from new to open
  • Component changed from unfiled to support

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 23 months 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 22 months 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 22 months ago by Dave Methvin

  • Status changed from open to closed
  • Resolution set to fixed

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 22 months ago by dmethvin

  • Milestone changed from None to 1.8

comment:6 Changed 21 months 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 19 months ago by anonymous

I can find the same code on version 1.7.1

comment:8 Changed 6 months ago by quentin

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.


Add a comment

Modify Ticket

as closed

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.