girliemac / filterous-2

Instagram-like photo manipulation library for Node.js and Javascript on browser
https://girliemac.github.io/filterous-2/demo-browser/
MIT License
206 stars 42 forks source link

Memory leak when adding filter to 100 images #2

Open Name-less opened 7 years ago

Name-less commented 7 years ago

Thanks for this library that work very well.

But when I apply a filter on server side with nodejs over 100 images one after another, the memory of the server increase to 300 Mo, and when it's over, the memory is not released and the server still take 300 Mo of memory until we restart it.

It is possible that the issue came from the node-canvas library used, see : https://github.com/Automattic/node-canvas/pull/1003

Are you compatible with node-canvas 2.0-alpha ?

Name-less commented 7 years ago

After some researches, a workaround is possible https://github.com/Automattic/node-canvas/issues/785

add img.src = null; on your importImage function on the onload callback

I will try it out ...

Name-less commented 7 years ago

Finally adding

process.nextTick(function() { img.onload = null; });

Fix the leak, I fork the project here : https://github.com/Name-less/filterous-2/releases/tag/2.0.2