question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory leak when running tests

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ricvealcommented, 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 https://github.com/angular/zone.js/pull/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.

1reaction
thymikeecommented, Aug 19, 2018

Thanks! That’s interesting, would be nice to have some more findings about that. Maybe it’s related to https://github.com/facebook/jest/issues/6814

Read more comments on GitHub >

github_iconTop Results From Across the Web

Your Jest Tests are Leaking Memory
Why does Jest leak memory? ... Jest resets the require cache between each test run. This is really nice because it gives test...
Read more >
Finding the cause of a memory leak in Jest tests
Memory leaks can be nasty and pretty hard to find. We found that the hard way. We should always make sure to clean...
Read more >
Memory Leak Testing in Continuous Integration Systems
Memory testing involves validating a C or C++ application's use of memory and looking for memory leaks or illegal management of memory, such...
Read more >
Memory Leak when running multiple test. Especially ... - GitHub
I'm seeing a memory leak while trying to run a basic autogenerated ( with "ng g c my-test" and "ng g c "my-test-2")...
Read more >
My Jests tests are leaking memory, how can I fix this?
First of all, make sure that you have leaky tests by running jest with the option: jest --logHeapUsage. Run your tests and check...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found