#8863 closed bug (fixed)
Memory leaks in IE(6/7/8) when refreshing a frame, which is in a frameset and includes latest jQuery (v.1.5.2)
Reported by: | Simeon Panayotov | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | 1.next |
Component: | support | Version: | 1.5.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
If jQuery is included in a frame in a frameset and the given frame is refreshed repeatedly, the browser (IE6/7/8) leaks memory. The leak is approximately 1MB per click. The bigger the page, the bigger the leak. I have tested this also with IEJSLeaksDetector, which shows that the window object is a possible leak (which would explain the size of the leak, provided the fact that there is only jQuery on the page.
I suspect this issue is the same as http://bugs.jquery.com/ticket/6421 and since the latter is closed I am opening a new ticket.
Below is the code of a three different pages: one with frameset with two frames, one with a link, hosted in the first frame, and a third one, hosted in the second frame. When the link is clicked the content of the second frame, containing jQuery, is refreshed.
main.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <html> <head> <frameset cols="50%,50%*" border="0" frameborder="1" framespacing="1"> <frame src="link.html" scrolling="no" frameborder="0" noresize="yes" /> <frame name="jqueryhost" src="" scrolling="no" frameborder="0" noresize="yes" /> </frameset> </head> <body> </body> </html>
link.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title></title> </head> <body> <a href="jqueryhost.html" target="jqueryhost">load jQuery in a frame"</a> </body> </html>
jqueryhost.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title></title> <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"></script> </head> <body> jQuery Host </body> </html>
I hope this helps you reproduce the issue.
Change History (21)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Resolution: | → patchwelcome |
---|---|
Status: | new → closed |
This is almost certainly an issue with Internet Explorer (obviously) but it's not obvious what the issue is (especially since jQuery simply existing is causing the problem). This is a case where we're going to have to defer to someone that wants to investigate and provide a patch.
comment:4 Changed 12 years ago by
Experiencing this same memory leak problem on HP t5510 thin clients running WinCE .NET 4.2's IE6. Reliably reproducible memory leak with jQuery 1.5.2, but jQuery 1.4.4 works fine.
comment:5 follow-up: 6 Changed 12 years ago by
Also seeing this issue. Selenium (which uses a frameset) slows to a crawl by simply including jQuery > 1.4.4 in the app under test.
Sad to see the reaction that this is simply an IE bug when it works fine with jQuery v1.4.4. Unfortunately that means my team will be stuck on this version.
comment:6 Changed 12 years ago by
Sad to see the reaction that this is simply an IE bug when it works fine with jQuery v1.4.4. Unfortunately that means my team will be stuck on this version.
"Patchwelcome" does not mean "wontfix", feel free to contribute a patch to the github repo if you are able to solve this issue. Thanks!
comment:7 Changed 12 years ago by
I created a simple frameset doc to test this issue in IE7. I also reproduced this issue with Jquery 1.5.1 and above even with version 1.6.1, but not with Jquery 1.5.0. It seems something happened in the Jquery 1.5.1 patch. Maybe it helps.
comment:8 Changed 12 years ago by
Moreover with Jquery 1.5.1 RC1 still working and detect no issue in frameset doc with IE7. The problem appears in the final version of Jquery 1.5.1 and above.
comment:9 Changed 12 years ago by
Ok. So most probably I found the problem. Let's see Jquery 1.5.1 source code for example. The problematic code line is 1106, which looks like this:
input = div.getElementsByTagName("input")[0];
I don't know why, but if you add this statement into a variable, then IE do this kind of memory issue. I tried to avoid this variable so I replaced 'input' variable with inline call where it was used. So I replaced on code line 1145
checkOn: input.value === "on",
to
checkOn: div.getElementsByTagName("input")[0].value === "on",
And code line 1163-1164:
input.checked = true; jQuery.support.noCloneChecked = input.cloneNode( true ).checked;
to
div.getElementsByTagName("input")[0].checked = true; jQuery.support.noCloneChecked = div.getElementsByTagName("input")[0].cloneNode( true ).checked;
And it worked. No more redundant memory consumption in IE7 and I think other IE versions. :)
comment:10 Changed 12 years ago by
Thanks romero83 for the input but it doesn't solve the problem for me :-( Also jQuery 1.4.4 is not working fine for me I also get a memory leak of about 1Mb per load. Any other ideas or a solution coming up from jQueries side?
comment:11 Changed 12 years ago by
romero83, an easier fix would be to clear the "input" variable on line 1313, where the other variables declared in the same place is set to null. I have successfully tested this change:
div = all = a = input = null;
comment:13 Changed 12 years ago by
Component: | unfiled → support |
---|---|
Priority: | undecided → high |
I think we should null the support vars.
comment:16 Changed 12 years ago by
Resolution: | patchwelcome |
---|---|
Status: | closed → reopened |
comment:17 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Null created elements in support to avoid leaks in IE. Tested IE6-8. Leaks are contained to the byte. Fixes #9294.
Changeset: 657b197c193335899703fc158b153e2475cca539
comment:18 Changed 12 years ago by
Thanks for your proposed solution but unfortunately it's not solving the problem in IE (still about 1Mb of leak)
comment:20 Changed 12 years ago by
@Booab There are no leaks in the support module in IE6 according to my tests. Do you have a test case I could view? Also, you are testing against the git version of jQuery correct?
comment:21 Changed 12 years ago by
@timmywil I added the source as described in the changeset manually to the versions of jQuery I'm testing on (1.4.4, 1.5.1, 1.6.1). Or is this not the way it should be done? I don't see a way to download the jQuery file with your changes in it, so I assume the manual way is correct?
I'll post my source once you acknowledge my way of working, if not I will test again with your suggestions (if I can download the full patch jQuery file).
We have the same problem.