Skip to content

Memory leak in version 2.0 #922

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

Closed
azangru opened this issue Jun 6, 2017 · 1 comment
Closed

Memory leak in version 2.0 #922

azangru opened this issue Jun 6, 2017 · 1 comment

Comments

@azangru
Copy link
Contributor

azangru commented Jun 6, 2017

Hi!

I have come across what seems to be a memory leak in node-canvas version 2. I've put together a very basic repro case that you can find in this repo.

Briefly, the problem manifests like this:

  • Start an app that uses node-canvas v.2
  • Send multiple requests to it
  • Observe the memory usage. Specifically, the rss portion of process.memoryUsage is quickly increasing despite garbage collection.

For example, in my repro case, the memory usage that started with:

{"rss":72290304,"heapTotal":21008384,"heapUsed":11065680}

rose after a 1000 requests to:

{"rss":643870720,"heapTotal":17862656,"heapUsed":11048840}

(notice the rise in rss).

This memory leak is not present in the 1.x branch of node-canvas.

I tried both .pngStream() and .toBuffer() methods in my repro case (since there is an issue regarding memory leaks with pngStream). None of this helped.

If you could suggest the place in the version 2 branch that is free from this leak, I would be super grateful. I've used the master branch of node-canvas in production this winter, and it seems like there was no such bug then.

My environment:
MacOS v. 10.11.6
node v6.7.0

P.S.: I have not bisected the git history to find the exact commit that has introduced the leak, but at least at the time of this March commit memory seems to be managed fine.

@zbjornson
Copy link
Collaborator

Thanks for the nice repro case. I can try to look at this within the next week, but if anyone else gets to this before me, go ahead please!

zbjornson added a commit to zbjornson/node-canvas that referenced this issue Jun 20, 2017
zbjornson added a commit to zbjornson/node-canvas that referenced this issue Jun 20, 2017
zbjornson added a commit to zbjornson/node-canvas that referenced this issue Jun 27, 2017
Don't recreate the cairo surface when the canvas is constructed.

Fixes Automattic#922
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants