title: javascript memory leak with HTML5 Canvas getImageData in Chrome browser for mac OSX
body: <p>this problem was fixed in the new chrome version(Version 35.0.1916.114)</p>
  
  <hr>
  
  <p>In <strong>chrome</strong> for <strong>mac osx</strong>, CanvasRenderingContext2D#getImageData function will make memory leaks, how can I avoid this problem, here is the test case and result, it's only happened in chrome browser, safari is OK</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;CanvasRenderingContext2D#getImageData bug in chrome&lt;/title&gt;
      &lt;script type="text/javascript"&gt;
  
      var g;
      function init(){
          g = document.getElementById('canvas').getContext('2d');
          g.fillStyle = "blue";
          g.fillRect(10, 10, 100, 100);
          g.fillStyle = "green";
          g.fillRect(60, 60, 100, 100);
      }
  
      function getImageData(){
          var i = 0;
          while(i++ &lt; 100){
          var c = g.getImageData(0,0,1000, 1000);
          delete c;
          }
      }
  
      function toDataURL(){
          var i = 0;
          while(i++ &lt; 100){
          var c = g.canvas.toDataURL();
          delete c;
          }
      }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onload="init()"&gt;
  &lt;button onclick="getImageData()"&gt;call getImageData 100 times - then memory will grow, can't GC&lt;/button&gt;
  &lt;button onclick="toDataURL()"&gt;call toDataURL 100 times - it is OK&lt;/button&gt;&lt;br&gt;
  &lt;canvas id='canvas' width='600px' height='500px'/&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/4TaTW.png" alt="enter image description here"></p>