Note that there are some explanatory texts on larger screens.

plurals
  1. POjqueryUI selectable causing memory leaks
    primarykey
    data
    text
    <p>jQuery-selectable is causing memory leaks. How can I prevent this? Is there something I am missing?</p> <p>I have a complex web app that uses multiple instances of jquery UI-selectable. I have been using sIEve to track memory leaks and I notice the number of leaks is equal to the number of ui-selectable instances.</p> <p>I wrote a simple test page that uses selectable as minimally as I could think of. In sIEve, it caused 1 memory leak (div#b).</p> <p>Here is the HTML:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt;&lt;title&gt;test leaks with selectable&lt;/title&gt; &lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="jquery-ui.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="testLeaks.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="b"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And here is testleaks.js:</p> <pre><code>function begin() { $('#b').selectable(); } function unloadCleanup() { $('#b').selectable('destroy'); $('#b').remove(); } $(window).unload(unloadCleanup); $(document).ready(begin); </code></pre> <p>I only included <code>unloadCleanup</code> and the <code>.unload</code> handler after I already saw the leak. It makes no difference with or without it.</p> <p>This seems to be evidence that simply activating jquery-selectable causes a memory leak.</p> <p>Next I changed testleaks.html to include sub-divs:</p> <pre><code>&lt;div id="b"&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>In sIEve, I loaded the page and selected one of the sub-divs. The number of resulting leaks was 11 - one for the selectable div itself, and one for each selectee.</p> <p>Selecting more than one sub-div did not increase the number of leaks. The number of leaks was 11 if any sub-divs were selected, and 1 if no sub-divs were selected.</p> <p>Using <strong>jQuery 1.6.4</strong>, and <strong>jQuery-UI 1.8.16</strong> with <strong>selectable</strong>, <strong>dialog</strong>, and <strong>datepicker</strong>, and the lightness theme.</p> <p>Is there something I'm doing wrong?</p>
    singulars
    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.
    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