-
-
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]: Jest increase heap usage after each test #14042
Comments
I read this commend and I used this node option: I tried this command:
This command reduce memory consumption of ~2GB ~3GB to ~1GB (max) But the memory leak problem persist: See this test: Jest says use 1GB when running with all tests But running alone, Jest says use 95MB |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
....Idk |
See #11956 By the looks of it, the issue is related to node rather then Jest itself. So don't worry, you're not the only one with this issue |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
I have the same issue as @SMH110 running a suite alongisde supertest. Running each test individually uses ~140MB but when running the entire suite it goes to like 6GB until crashing. By looking at heap inspection i see up to 4GB of compiled (with babel-jest) code as string. Why jest compiles the same files over and over again and they are not cleared? |
This issue is bothering us too. We are constantly overflowing our build server because the test files do not get cleared. |
This is also causing us issues, we still have the issue after updating to node 18, which we had hoped would fix the issue. |
I'm also having trouble with jest increasing heap memory. You also can use the flag |
When jest starts spinning off multiple nodes and they're all eating up the RAM it makes my machine come to a crawl. I've also been experiencing random hangs. Our test suite of nearly 2k tests used to be able to run in 35-55 seconds averaging about 45 seconds, my current test hung and then crawled and took 350 seconds :\ I imagine part of this is due to the RAM, I'm on an M1 Macbook Pro with 16GB, but when these tests start taking up tons of RAM it starts to hit the page swap and compression and slows everything down. It's not the RAMs fault per-say but a side effect of the tests taking up way too much RAM. I shouldn't see my test suite spiking up 8-16GB of RAM when I run it. When I measure the memory heap it will get up to about 2gb then seems to clean up and drop down to 1.5gb and climbs back up again. This is when it's in a single thread though. Once it's running there are several node instances using up that much each. We're on: @maximelafarie I was just reading that article yesterday, but haven't had time to dig into this, just checked out the heap flag and noticed it growing, dropping (likely GC), and growing again. Edit: tried locking in: |
I've switched over to Been stuck trying to get our coverage to work with This comment kulshekhar/ts-jest#1967 Edit/Update: We switched over to Also found that the coverage shenanigans were patched in ts-jest here: And found the following open bugs with a proposed similar fix: |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
✅ This worked for us. It was passing on our local machine but was failing in our pipelines on Azure, even after allocating more resources. We suspect that one of the causes of our issue was the use of Inversify. During each test, we had to spin up and rebind containers. Using the --no-compilation-cache node option resolved our issue for the time being. |
We had the same issue so I did a work around until this issue gets fixed, |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
I assume this is a duplicate of #11956. If not please open up a new issue with a minimal reproduction. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
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
29.5.0
Steps to reproduce
--detectOpenHandles --logHeapUsage --forceExit --clearMocks
Expected behavior
Jest not use a lot of memory
Actual behavior
When I run tests with
--logHeapUsage
then starts using ~130MB of memory and after some tests the heap usage increase between 2GB and 3GB...command:
craco test --watchAll=false --detectOpenHandles --logHeapUsage --forceExit --clearMocks
This test uses ~1500MB of memory
But when I run him specifically the heap use is ~150MB
How to find the problem and solve it?
Additional context
Related:
#11956
I tried to use
workerIdleMemoryLimit
but not worksDocs:
https://jestjs.io/docs/next/configuration#workeridlememorylimit-numberstring
Command:
craco test --watchAll=false --coverage --detectOpenHandles --logHeapUsage --forceExit --clearMocks --workerIdleMemoryLimit=500MB
Result:
Environment
The text was updated successfully, but these errors were encountered: