How can I free the allocated memory with <canvas> in the following example:
<html>
<head>
</head>
<body id="body">
<canvas id="canvas" width=3000 height=2000/>
<script>
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.fillText("hao ar iu?", 20, 20);
</script>
</body>
</html>
I tried to set var canvas to null (canvas = null), delete the canvas (delete the canvas), or dynamically create the canvas and add it to the "document" root after deleting it this way:
<div onclick=reload()>CLICK TO RELOAD PAGE</div>
<script>
function reload(){
body.removeChild(canvas);
location.reload();
}
</script>
Nothing changes, the allocated memory becomes more and more each time I reload one page, until my browser takes up too much RAM of the processor. Sometimes the browser crashes. Sometimes the garbage collector clears some variables from the volume. But this allows you to take up too much memory. I am using Chrome version 25. Are there any means to free up <canvas> memory or trigger early garbage collection?