I have a canvas element, and a button that calls the covertCanvasToImage() function. imageAsFile is just a div where an image element is added. imageToSave is global, and keeps being reused. No additional image elements are continuously added to the page, yet when I look at the sources in the inspector, new images keep being added, making the memory use go up and up. How do I keep it from leaking?
var imageToSave = new Image();
function convertCanvasToImage() {
imageToSave.src = canvas.toDataURL("image/png");
document.getElementById('imageAsFile').appendChild(imageToSave);
}