-
-
Notifications
You must be signed in to change notification settings - Fork 6.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]: --runInBand seems to leak memory when importing the same module multiple times #12142
Comments
Also I've noticed that previous versions were faster on CI. on 25 and 26 locally 40s, on CI 4min. After update to 27 locally 25s but on CI timeout after 25min |
any ideas of how to fix it? |
We ran into the same issues. I did a little benchmark to know if switch to a different test framework would solve the issue. Doing that discovered that the leaks accentuate with leaving opened handles: https://github.com/grissius/jest-is-a-rude-needy-clown-and-eats-lot-of-memory#leakables |
Using this approach from @oskar-kupski-elpassion reduces the memory leaks for me. Also, if you're using typescript with |
@leonardopliski |
As mentioned in #7874 (comment) I think the cached strings are red herrings (and if they're not, Node needs to expose some API). From the linked reproduction in the OP (really well put together, thank you!) I think you can see the same. While memory usage increased, it also drops when GC has run (and running with |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Version
27.4.4
Steps to reproduce
Any version since 25.1.0 seems to leak memory when running with --runInBand
npm run build
npm run test27
, attach a debugger and check memory dump at the end of testsExpected behavior
Lodash module string once in memory
Actual behavior
Dozens of instances of lodash module string in memory
(this is the memory snapshot for jest 25)
Additional context
We have seen this behavior in our application where we use --runInBand to run in CI.
All versions I have tested between 25.1.0 - 27.4.4 have this issue.
24.9.0 seems to still be okay, as can be seen by running
npm run test24
.Environment
The text was updated successfully, but these errors were encountered: