title: Does JavaScript garbage collect this?
body: <p>Every once in a while I find myself doing something along the lines of the following</p>
  
  <pre><code>var img = new Image();
  img.src = 'php/getpic.php?z=' + imid + '&amp;th=0';
  img.onload = function(){drawImages(img,contexts,sizes)};
  </code></pre>
  
  <p>Explanation</p>
  
  <ol>
  <li>Create an HTML image element.</li>
  <li>Assign its src attribute</li>
  <li>Assign its onload event</li>
  <li>Pass one or more Canvas contexts to the event handler </li>
  <li>Draw the loaded image to the canvases</li>
  </ol>
  
  <p>The thing I am not clear about is this - will the JavaScript garbage collector deal with the task of discarding the img element or do I need to do it myself or else face a slooow memory leak?</p>