LearnBoost/node-canvas — Issue #150: Image Memory Leak
Author: drwheeler
Created: 2012-02-02 01:31:29+00:00
State: open

This simple little loop chews through all the memory on my Debian box. I'm nulling the Image instance every time through.
Running with node --trace_gc tst6.js shows that garbage collection is happening but this script will use 2GB of memory in short order then get killed. In real life the interval would be 10s

...

setInterval(timestampImage, 100);

function timestampImage() {
var cameraImage = new Image;

cameraImage.onload = onLoad;
cameraImage.onerror = function(err) {
console.log(err);
};

cameraImage.src = blackJpeg;

cameraImage = null;
}

function onLoad() {

...

Put the image in a canvas, add a text timestamp, save

...

}

https://gist.github.com/1720778#file_timestamp.js