Skip to content
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

Reduce leaked memory via domains and timers #681

merged 1 commit into from Mar 6, 2017


Copy link

cjihrig commented Mar 5, 2017

This commit improves retained memory usage in a few ways.

  • Removes things from domains that are explicitly added.
  • Isolate closures in separate functions so that they only capture the mimimim number of variables.
  • Initialize several global event emitters prior to creating any domains. Currently, this is process.stdout, process.stderr, and the cluster module. Once these are initialized, they hold on to whatever the current domain is for the rest of the program execution. This is not an exhaustive list, so I'm not sure if we actually want to do this or not.

There are other improvements to be made in both lab and hapi, but I think this is a good first step. Using a modified version of hapi, I took heap snapshots in a process exit handler and saw memory usage drop from ~45MB to ~19MB when running the test suite.

@geek geek changed the title reduce leaked memory via domains and timers Reduce leaked memory via domains and timers Mar 6, 2017
@geek geek self-assigned this Mar 6, 2017
@geek geek added the bug label Mar 6, 2017
@geek geek added this to the 13.0.0 milestone Mar 6, 2017
@geek geek merged commit 6986871 into hapijs:master Mar 6, 2017
2 checks passed
2 checks passed
Node Security No known vulnerabilities found
continuous-integration/travis-ci/pr The Travis CI build passed
@cjihrig cjihrig deleted the cjihrig:domains branch Mar 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.