-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Memory leak when creating canvas in node #4449
Comments
Tomorrow ill clone the repo and try. |
I updated the repo to include what I consider the equivalent in |
I'm sorry i worked on other fabricjs things instead of this. About node: For this reason all the nodejs specific code should be deleted. The idea is to remove all the code nodejs specific code and look at the situation again. |
No problem. For now we've gone back to the stable release. As long as it's on the todo list :) |
starting to investigate node now. Starting with issue #4231, trying to remove node code and possibly memory leak will auto resolve |
I changed the code like this, removing the fabric.Canvas creation and creating a JSDOM canvas const fabric = require('fabric').fabric;
function createCanvas(){
const canvas = fabric.document.createElement('canvas');
global.gc();
console.log(process.memoryUsage());
setTimeout(createCanvas, 1000);
}
createCanvas(); start:
after on hour:
If i create a fabric.StaticCanvas() const fabric = require('fabric').fabric;
function createCanvas(){
const canvas = new fabric.StaticCanvas(null, {width: 200, height: 200});
canvas.clear();
canvas.dispose();
global.gc();
console.log(process.memoryUsage());
setTimeout(createCanvas, 1000);
}
createCanvas(); i start like this:
and after a bit i m like:
and growing |
i can get to a decent amount of iteration inside 800k. It looks like the memory consuption comes from instatiating node canvas elements.
|
Latest build plus those changes i applied in the PR, brought me in a situation in which memory was oscillating and then stabilize:
|
Version
v2.0.0-beta.7
Test Case
https://github.com/RckMrkr/fabric-memory-demo
Sorry, I'm not aware of any node equivalent of jsfiddle, so I tried to create a minimal test case.
Steps to reproduce
Create canvas object in node and then force garbage collection. Do that a few times.
Expected Behavior
The memory usage should stay the same between iterations.
Actual Behavior
The (external) memory increases for each constructed canvas.
I did try the equivalent test in node-canvas, and all memory stayed the same after each creation.
The text was updated successfully, but these errors were encountered: