Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting img.src to dataUrl Leaks Memory
    primarykey
    data
    text
    <p>Below I've created a simple test case that shows that when an img tag's src is set to different dataUrls, it leaks memory. It looks like the image data is never unloaded after the src is changed to something else.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Leak Test&lt;/title&gt; &lt;script type="text/javascript"&gt; canvas = null; context = null; image = null; onLoad = function(event) { canvas = document.getElementById('canvas'); context = canvas.getContext('2d'); image = document.getElementById('image'); setTimeout(processImage, 1000); } processImage = function(event) { var imageData = null; for (var i = 0; i &lt; 500; i ++) { context.fillStyle = "rgba(" + Math.floor(Math.random() * 256) + "," + Math.floor(Math.random() * 256) + "," + Math.floor(Math.random() * 256) + "," + Math.random() +")"; context.fillRect(0, 0, canvas.width, canvas.height); imageData = canvas.toDataURL("image/jpeg", .5); image.src = imageData; } setTimeout(processImage, 1000); } &lt;/script&gt; &lt;/head&gt; &lt;body onload="onLoad(event)"&gt; &lt;canvas id="canvas"&gt;&lt;/canvas&gt; &lt;img id="image"&gt;&lt;/img&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>If you load this html page, RAM usage builds over time and is never cleaned up. This issue looks very similar: <a href="https://stackoverflow.com/questions/9913765/rapidly-updating-image-with-data-uri-causes-caching-memory-leak">Rapidly updating image with Data URI causes caching, memory leak</a> . Is there anything I can do to prevent this memory leak? </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.
 

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