Bug Tracker

Opened 12 years ago

Closed 12 years ago

#8450 closed bug (worksforme)

Memory Leak when removing objects (leaving orphans)

Reported by: [email protected] Owned by:
Priority: high Milestone: 1.next
Component: manipulation Version: 1.5
Keywords: Cc:
Blocked by: Blocking:


Using jQuery1.5 I am seeing orphans left in my DOM.

http://img651.imageshack.us/i/leakl.png/ http://img651.imageshack.us/i/leakl.png/

I am updating a web interface once per second (stock market ticks) and I am getting a small memory leak over time.

This is causing me a problem for an application designed to be left open on a big screen for upto 24 hours at a time.

In my real code I am hitting 1.5Gb usage in IE after 24hours, from a 32mb start point.

I have put limited code to reproduce below. Any ideas? Perhaps I have made some mistake somewhere causing this, but I have never looked at jQuery so closely before so apologies if I am being silly.

Code to reproduce:

    <script src="/Scripts/jquery.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(function () {

        function reload() {
            $("#container").append("<div class='test'>Item</div>");

    <div id='container'>


Change History (9)

comment:1 Changed 12 years ago by anonymous

Working on jsFiddle now.

comment:3 Changed 12 years ago by Rick Waldron

Component: unfiledmanipulation
Priority: undecidedhigh
Status: newopen

This may not affect your leak issue, but I would recommend not using setInterval(), but instead create your reloading loop with a recursing setTimeout().

comment:4 Changed 12 years ago by adam.king89

Can confirm changing to setTimeout() doesn't seem to fix the problem.

Curious as to reasoning behind using recursion? I thought I would be best avoiding it in order to keep the stack size down?


comment:5 Changed 12 years ago by Rick Waldron

setInterval swallows errors that occur inside the interval, so if the code is broken, it will repeat the broken code instead of stopping on the exception

comment:6 Changed 12 years ago by olau

This sounds as if it is related to bug 5285.

comment:7 Changed 12 years ago by olau

What exact version of IE are you on?

The test case in 5285 is very similar, and gives me orphans in sieve too, but when I try it in plain IE 6, 7 and 8 from the IE Collection, there doesn't appear to be a leak. I don't seem to be getting one from your test case on jsFiddle either. So I'm beginning to wonder whether sieve is trustworthy these days.

Sorry for interrupting, but I'm trying to debug a similar problem and it's certainly not easy to pinpoint where the issue is.

comment:8 Changed 12 years ago by [email protected]


I have tested across different IE versions. I am away from my desk at the moment but I will update accordingly when I am home.

I have tested using both sIEve and Drip, but I don't know how correct they are, I assumed they were trustworthy but you might have a point in that that might be part of the issue.

I'd not heard of IE Collection until just now, I'll run a few experiments over night using it tonight.



comment:9 Changed 12 years ago by Rick Waldron

Resolution: worksforme
Status: openclosed
Note: See TracTickets for help on using tickets.