Ticket #9341 (closed bug: fixed)
IE7/IE9 memory leak creating cacheable HTML fragments
| Reported by: | shghs | Owned by: | rwaldron |
|---|---|---|---|
| Priority: | high | Milestone: | 1.next |
| Component: | core | Version: | 1.6.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Calling the jQuery function with an HTML string that is not matched by rsingleTag leads to a memory leak in IE7 and IE9.
Steps to reproduce:
- Restart Windows.
- Run the task manager (Ctrl+Alt+Del) and switch to the process tab.
- Run IE and load the attached test case.
Result: iexplore.exe's memory usage linearly increases. On my machine, it uses 16 MB after the first page load, and over 100 MB after 2 minutes.
This affects:
- IE 7.0.5730.11 on Windows XP SP3
- IE 9.0.8112.16421 on Windows 7 x64 SP1
both running in VMware Fusion. The memory leak is not present in jQuery 1.5.
Change History
comment:2 follow-up: ↓ 4 Changed 2 years ago by shghs
On further testing, it looks like even jQuery('<div>') leaks in IE7. IE9 needs an HTML string that isn't matched by rsingleTag, so maybe these are actually two separate bugs?
comment:3 Changed 2 years ago by timmywil
- Priority changed from undecided to high
- Resolution set to patchwelcome
- Status changed from new to closed
- Component changed from unfiled to core
Avoiding leaks is important, but we probably won't be able to invest resources in fixing this. Regardless, patches are welcome if the source of the leak can be discovered.
comment:4 in reply to: ↑ 2 ; follow-up: ↓ 7 Changed 2 years ago by jwyles@…
Replying to shghs:
On further testing, it looks like even jQuery('<div>') leaks in IE7. IE9 needs an HTML string that isn't matched by rsingleTag, so maybe these are actually two separate bugs?
I did some investigation, i think there is a memory leak with $.support in ie7 which may be causing the jQuery('div') leak, hopefully get some time to write up a test case for that.
comment:5 Changed 2 years ago by rwaldron
- Status changed from closed to reopened
- Resolution patchwelcome deleted
I predicted this.
We used to null all elements and those elements' outerHTML that were created in the support tests, then the nulling was removed. Looks like it needs to be re-added.
comment:6 Changed 2 years ago by rwaldron
- Owner set to rwaldron
- Status changed from reopened to assigned
comment:7 in reply to: ↑ 4 Changed 2 years ago by shghs
Replying to jwyles@…:
I did some investigation, i think there is a memory leak with $.support in ie7 which may be causing the jQuery('div') leak, hopefully get some time to write up a test case for that.
Yes you're right. IE7 has a separate memory leak due to #8873 which is reproducable just by including jQuery and no other JavaScript.
So I think this bug actually only affects IE9 and I flagged IE7 prematurely.
comment:8 Changed 2 years ago by shghs
I've submitted a pull request here: https://github.com/jquery/jquery/pull/389
and also raised a ticket on IE's bugtracker: https://connect.microsoft.com/IE/feedback/details/670128/memory-leak-related-to-documentfragment-prototype-queryselectorall
comment:10 follow-up: ↓ 11 Changed 2 years ago by rwaldron
@dmethvin - I think there is some confusion, shghs didn't find that, he filed that. I'm following the ticket now to see if there is any action. Seems odd that we're just now getting reports of this leak. My biggest concern is compromising performance for all UAs over a phantom
comment:11 in reply to: ↑ 10 Changed 2 years ago by shghs
Replying to rwaldron:
My biggest concern is compromising performance for all UAs over a phantom
The line of code in question is only reached in IE8 and IE9.
I agree it's odd that this leak hasn't been reported before. It's existed since 1.5.2, but it would probably be a good idea to do some more comprehensive testing in case this bug is unique to my VM environment.
comment:12 Changed 2 years ago by Scott Hughes
- Status changed from assigned to closed
- Resolution set to fixed
Landing pull request 389. Null elements in clone to avoid memory leak in IE. Fixes #9341.
More Details:
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Test case: http://jsfiddle.net/nGs5t/