Bug Tracker

Opened 12 years ago

Closed 10 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)

jquery-iefix.diff (1.7 KB) - added by henric 12 years ago.
patch against 1.2.6
test1000.html (525 bytes) - added by henric 12 years ago.
Variant of documentation's html API example

Download all attachments as: .zip

Change History (8)

Changed 12 years ago by henric

Attachment: jquery-iefix.diff added

patch against 1.2.6

comment:1 Changed 12 years ago by flesler

Component: coreajax
Milestone: 1.3
need: ReviewTest Case
Priority: majortrivial
Type: bugenhancement

Can you provide a concise test case to reproduce the leak ?

Changed 12 years ago by henric

Attachment: test1000.html added

Variant of documentation's html API example

comment:2 in reply to:  1 ; Changed 12 years ago by 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.

comment:3 in reply to:  2 Changed 12 years ago by henric

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 10 years ago by IvanTheBearable

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 10 years ago by snover

Status: newpending

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 10 years ago by trac-o-bot

Status: pendingclosed

Automatically closed due to 14 days of inactivity.

Note: See TracTickets for help on using tickets.