Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>First</strong> off, there is no browser that I know of that leaks when you go to another page just because you have images stored in a JS array.</p> <p>There are some older browsers that leak if you have circular references between DOM &lt;==> JS where some javascript refers to a DOM element and a custom attribute on the DOM element refers back to the same javacript object, but that does not appear to be what you have here.</p> <p>So ... I'd be surprised if what you're seeing is actually a leak in going from one page to the next. If you're convinced it is, then create either a plain web page that you can share with us or a jsFiddle that shows the issue and tell us what exact browser you're testing in and exactly how you're measuring the memory usage that determines you have a leak. </p> <p>For it to truly be a leak, you have to consistently see memory usage go up and and up and up, every time you go to the page over and over again. Just because total memory usage is a little bit higher the second time you go to the page does not mean you have a leak. The browser has some data structures that grow (to a point) with usage like the memory-based cache, the session browsing history, etc... that are not indicative of leaks.</p> <p><strong>Second</strong> off, I don't see anything in the data structures you've shown that are illustrative of the kinds of circular references that are known to cause leaks in older browsers.</p> <p><strong>Third</strong> off, the <code>delete</code> operator is for removing properties from an object. That's all it's for. See these articles: <a href="http://perfectionkills.com/understanding-delete/" rel="noreferrer">Understanding Delete</a> and <a href="https://developer.mozilla.org/en/JavaScript/Reference/Operators/Special_Operators/delete_Operator" rel="noreferrer">MDN Delete</a> for a lot more explanation. So, your cleanup code in the unload handler is not using <code>delete</code> properly. You cannot delete vars or array elements with <code>delete</code>. Though I can't see any reason why this code is necessary, if you were going to have it, it would be like this:</p> <pre><code>// allow garbage collection by removing references $(window).unload(function() { for (var i = 0; i &lt; imgObjs.length; i++) { imgObjs[i] = null; } imgObjs = null; } </code></pre>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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