Opened 15 years ago
Closed 12 years ago
#3163 closed enhancement
IE pseudo-leak
Reported by: | henric | Owned by: | |
---|---|---|---|
Priority: | trivial | Milestone: | 1.3 |
Component: | ajax | Version: | 1.2.6 |
Keywords: | memory leak | Cc: | |
Blocked by: | Blocking: |
Description
sIEve reports DOM leaks for AJAX stuff. In the particular case I was debugging, with a .load() every few seconds replacing the contents of a <div>, unless things are attached to the root document in some way when "freed", they will apparently not be reclaimed until the page is reloaded. IE's memory usage, as seen in Task Manager, reports the same thing (after a few hours, IE will crash).
I pilfered and integrated a fix that seems to resolve this particular problem for me, but as this constitutes my first toe-in-the-water with JavaScript (more like head first into a pool w/o water), I am more than a little wary of unintentional side-effects this change may cause. The extra code should probably be conditional on browser.msie and could possibly be made more efficient (do the innerHtml thing on batches of objects)--and that's assuming that it is the right thing to do in the first place (for IE anyway).
I've seen "discardElement" and similar code in a number of place; I don't recall where I originally got it. I also suspect that the jQuery folks have seen similar code but have chosen not to use it.
I've attached a patch from 1.2.6 to what I'm running. It does seem to solve my problem; I make no further claims...
Attachments (2)
Change History (8)
Changed 15 years ago by
Attachment: | jquery-iefix.diff added |
---|
comment:1 follow-up: 2 Changed 15 years ago by
Component: | core → ajax |
---|---|
Milestone: | → 1.3 |
need: | Review → Test Case |
Priority: | major → trivial |
Type: | bug → enhancement |
Can you provide a concise test case to reproduce the leak ?
Changed 14 years ago by
Attachment: | test1000.html added |
---|
Variant of documentation's html API example
comment:2 follow-up: 3 Changed 14 years ago by
Replying to flesler:
Can you provide a concise test case to reproduce the leak ?
In the attached "test1000.html," I've added a for loop to the documentation's html(val) example. The "fixed" version reports 12017 DOM nodes in use (and ~62MB of RAM). Using 1.2.6 reports 19017 DOM nodes in use (~102MB of RAM).
Ideally, the DOM usage should be the same regardless of the constant in the for loop.
Oh, I'm on Vista Ultimate x64 using sIEve-0.8.0.
comment:3 Changed 14 years ago by
Replying to henric:
Replying to flesler:
Can you provide a concise test case to reproduce the leak ?
In the attached "test1000.html," I've added a for loop to the documentation's html(val) example. The "fixed" version reports 12017 DOM nodes in use (and ~62MB of RAM). Using 1.2.6 reports 19017 DOM nodes in use (~102MB of RAM).
Ideally, the DOM usage should be the same regardless of the constant in the for loop.
Oh, I'm on Vista Ultimate x64 using sIEve-0.8.0.
Errrr... that should read: sIEve-0.0.8
(And Vista has SP1.)
comment:4 Changed 13 years ago by
This is called a "pseudo leak" by Microsoft because the memory is eventually reclaimed when the page unloads. However, in modern ajax style applications where the page does not unload often, it is a very real leak.
The issue is that removeChild retains some sort of internal reference to a node so it is never freed. Emptying a node by setting innerHTML to "" does not have this problem. The issue still exists in IE8.
A possible solution is described at the end of this page: http://www.outofhanwell.com/ieleak/index.php?title=Fixing_Leaks
comment:5 Changed 12 years ago by
Status: | new → pending |
---|
This ticket has been marked as missing a test case. In an effort to reduce the number of outstanding tickets in the bug tracker, it will be closed automatically in 30 days. In order to prevent this from happening, please provide a working test case. If a test case has already been provided and our records are wrong, please respond to the ticket so that it can be fixed. Thank you!
comment:6 Changed 12 years ago by
Status: | pending → closed |
---|
Automatically closed due to 14 days of inactivity.
patch against 1.2.6