Bug Tracker

Modify

Ticket #3163 (closed enhancement)

Opened 5 years ago

Last modified 3 years ago

IE pseudo-leak

Reported by: henric Owned by:
Priority: trivial Milestone: 1.3
Component: ajax Version: 1.2.6
Keywords: memory leak Cc:
Blocking: Blocked by:

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

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

Change History

Changed 5 years ago by henric

patch against 1.2.6

comment:1 follow-up: ↓ 2 Changed 5 years ago by flesler

  • need changed from Review to Test Case
  • Priority changed from major to trivial
  • Type changed from bug to enhancement
  • Component changed from core to ajax
  • Milestone set to 1.3

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

Changed 5 years ago by henric

Variant of documentation's html API example

comment:2 in reply to: ↑ 1 ; follow-up: ↓ 3 Changed 5 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 5 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 3 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 3 years ago by snover

  • Status changed from new to 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 3 years ago by trac-o-bot

  • Status changed from pending to closed

Automatically closed due to 14 days of inactivity.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.