title: What is causing my console crash?
body: <p>I'm having problems with a bit of code I've written that cycles through an array of ads. 
  The render function gets called on an interval (configurable, but set to every 50ms to help with debugging). The problem is, when this function runs too many times, the console crashes. On some mobile phones, the device will run out of memory completely and restart itself, and I think it's related to this function (console doesn't crash if I take it out):</p>
  
  <pre><code>var render = function(){
      if(ads.length &lt; 1)
          return;
      if(!ads[adIndex]){
          adIndex = 0;
      }
      s = ads[adIndex].src;
      w = ads[adIndex].width;
      $(adContainer).html("&lt;p&gt;ADVERTISEMENT&lt;/p&gt;&lt;img src = '" + s + "' width = '" + w + "'/&gt;");
      adIndex++;
  };
  </code></pre>
  
  <p>I'm thinking it might be a memory leak, but I'm not a memory expert by any means.  Is there something I can do to optimize this function and prevent memory issues?</p>
  
  <p>Edit: I'm calling the code like this:</p>
  
  <pre><code>setInterval(function(){
          render();
      }, 50);
  </code></pre>
  
  <p>And the ads array is simply an array of javascript Image() objects.</p>