Skip to main content

Bug Tracker

Side navigation

#3163 closed enhancement ()

Opened July 16, 2008 01:03AM UTC

Closed November 11, 2010 11:09PM UTC

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 July 16, 2008 01:03AM UTC.

    patch against 1.2.6

  • test1000.html (0.5 KB) - added by henric August 15, 2008 06:46PM UTC.

    Variant of documentation's html API example

Change History (6)

Changed July 22, 2008 01:33AM UTC by flesler comment:1

component: coreajax
milestone: → 1.3
need: ReviewTest Case
priority: majortrivial
type: bugenhancement

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

Changed August 15, 2008 06:55PM UTC by henric comment:2

Replying to [comment:1 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.

Changed August 15, 2008 07:02PM UTC by henric comment:3

Replying to [comment:2 henric]:

Replying to [comment:1 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.)

Changed April 12, 2010 04:43AM UTC by IvanTheBearable comment:4

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

Changed October 14, 2010 03:14AM UTC by snover comment:5

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!

Changed November 11, 2010 11:09PM UTC by trac-o-bot comment:6

status: pendingclosed

Automatically closed due to 14 days of inactivity.