Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery (2.0.2) empty() html() Memory Consumption Continually Grows
    primarykey
    data
    text
    <p>I've been struggling with this issue for 3 days now and am hoping someone has some tidbit of information which I haven't come across yet to help me out (i'm desperate!). To provide some context:</p> <p>Browser: IE9.0.8112.16421 (64 bit); jQuery version: 2.0.2</p> <p>Essentially what i'm doing is making a simple ajax call and retrieving some information which i'm then inserting into a element via the success handler. The relevant lines of code are shown below: </p> <pre><code>var onLoadViewGroupSuccess = function(data) { var target = $("#viewGroupContent"); //for(var i=0;i&lt;1000;i++) { target.empty().html(data); //} } </code></pre> <p>The target corresponds to the following html tag:</p> <pre><code>&lt;tr id="viewGroupContent"&gt;...&lt;/tr&gt; </code></pre> <p>The commented out for loop above is intended to magnify the issue (which is difficult to detect via single event click triggers). Essentially when the loop is in place, memory for a single invocation goes from 46MB to ~113MB. </p> <p>Subsequent calls exhibit the same behavior with memory continually growing. I initially thought it was an issue with some event handler which I failed to cleanup but ruled this out as I commented out virtually all my javascript logic so the below above is essentially all there is (i.e. no event handlers bound, no custom objects or functions invoked) - i.e. not a closure issue. </p> <p>Moving the for loop outside the ajax call (so making 1000 ajax calls) results in the same memory profile (so ruled out any obscure ajax memory leaks). The content i'm inserting is a TD tag containing a significant amount of content (i.e. instances of every HTML tag you can think of including images) so wondering if the content i'm inserting is somehow responsible for the leak.</p> <p>I've read some interesting blog posts regarding IE's ability to cleanup after itself including the following which seems the most promising (<a href="http://com.hemiola.com/2009/11/23/memory-leaks-in-ie8/">http://com.hemiola.com/2009/11/23/memory-leaks-in-ie8/</a>). Unfortunately, no solutions or workarounds thus far.</p> <p>I'm at a loss as i've stripped my app down to the bare bones and not much you can do with <code>$(...).empty().html(...)</code>. The memory leak is slow but persistent....</p> <p>Also, as an FYI, i've tried non jQuery solutions with innerHTML, DOM methods to remove the table row and rebuild it and then inserting the ajax content into the table cells, moving the discarded content to a garbage bin DIV and then invoking innerHTML, all to no avail, and in many cases making the leak worse...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload