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

Memory leak when running tests #186

Closed
chris5287 opened this issue Aug 19, 2018 · 7 comments
Closed

Memory leak when running tests #186

chris5287 opened this issue Aug 19, 2018 · 7 comments

Comments

@chris5287
Copy link

chris5287 commented Aug 19, 2018

Somewhere within the jest preset angular setup it causes memory leaks on every test.

REPL: https://github.com/chris5287/repl-jest-preset-angular-leak

When removing import "jest-preset-angular"; from setupJest.ts, no memory leaks are detected.

image

@thymikee
Copy link
Owner

Thanks! That's interesting, would be nice to have some more findings about that. Maybe it's related to jestjs/jest#6814

@chris5287
Copy link
Author

@thymikee not sure how to investigate this further, any ideas?

@me-12
Copy link

me-12 commented Oct 1, 2018

We experience the same issue. For us it is zone.js that causes the problem.
require('zone.js/dist/zone.js');

@ricveal
Copy link

ricveal commented Oct 23, 2018

We were experimenting same memory leak problems during testing in our codebase (with 1K tests more or less). As @me-12 has mentioned, the problems seems to be related with zone.js.

I have been checking this PR angular/zone.js#1106 that seems to fix the problem. It is merged in zone.js but the current deployed version of the library (0.8.26) still does not include these PR so we are waiting for the official release of a new zone.js version.

Meanwhile, we are using an updated repo (thank you @JiaLiPassion) in our package.json:

{
  "zone.js": "git://github.com/JiaLiPassion/zone.js#20181005-dist"
}

It is not the perfect solution but temporally solves the problem.

Anyway, jest --detectLeaks still fails us but the --logHeapUsage option shows a correct manage of memory by jest.

@ahnpnl
Copy link
Collaborator

ahnpnl commented Oct 23, 2018

@ricveal thank you very much for keeping us updated information. I'm looking forward to the fix from zone.js too.

@thymikee do you have any information regarding to the issue with detectLeaks ?

@thymikee
Copy link
Owner

--detectLeaks may be connected with something different, e.g. listener or server/db connection not being released. Cool they fixed the leak!

@ahnpnl
Copy link
Collaborator

ahnpnl commented Sep 12, 2019

Zonejs released 0.8.27 which includes the fix for memory leak with jsdom.

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

No branches or pull requests

5 participants