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 on ridiculously simple repo #7874

Open
javinor opened this issue Feb 12, 2019 · 118 comments
Open

Memory Leak on ridiculously simple repo #7874

javinor opened this issue Feb 12, 2019 · 118 comments
Labels

Comments

@javinor
Copy link
Contributor

javinor commented Feb 12, 2019

You guys do an awesome job and we all appreciate it! 🎉

🐛 Bug Report

On a work project we discovered a memory leak choking our CI machines. Going down the rabbit hole, I was able to recreate the memory leak using Jest alone.

Running many test files causes a memory leak. I created a stupid simple repo with only Jest installed and 40 tautological test files.

jest-memory-leak

I tried a number of solutions from #7311 but to no avail. I couldn't find any solutions in the other memory related issues, and this seems like the most trivial repro I could find.

Workaround :'(

We run tests with --expose-gc flag and adding this to each test file:

afterAll(() => {
  global.gc && global.gc()
})

To Reproduce

Steps to reproduce the behavior:

git clone [email protected]:javinor/jest-memory-leak.git
cd jest-memory-leak
npm i
npm t

Expected behavior

Each test file should take the same amount of memory (give or take)

Link to repl or repo (highly encouraged)

https://github.com/javinor/jest-memory-leak

Run npx envinfo --preset jest

Paste the results here:

System:
    OS: macOS High Sierra 10.13.6
    CPU: (4) x64 Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
  Binaries:
    Node: 10.15.0 - ~/.nvm/versions/node/v10.15.0/bin/node
    Yarn: 1.12.3 - /usr/local/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v10.15.0/bin/npm
  npmPackages:
    jest: ^24.1.0 => 24.1.0
@milesj
Copy link

milesj commented Feb 12, 2019

I found this out recently but you can use the Chrome console to debug Node scripts! You can try using the Chrome console to profile Jest while it's running to try and dig into the issue.

I believe the command is: node --inspect ./node_modules/.bin/jest --watch -i. When running, open Chrome and go to about:inspect. You should then see the running Node script.

@jeysal
Copy link
Contributor

jeysal commented Feb 12, 2019

Do I understand correctly that using the workaround to force GC runs makes the heap size remain constant? In that case it's not really a memory leak, just v8 deciding not to run the GC because there is enough memory available. If I try running the repro with 50MB heap size

node --max_old_space_size=50 node_modules/.bin/jest --logHeapUsage --runInBand --config=jest.config.js

the tests still complete successfully, supporting this assumption.

@javinor
Copy link
Contributor Author

javinor commented Feb 12, 2019

@milesj I ran through some memory dumps, but couldn't make much sense of them, I'm not too experienced with pursuing leaks and I didn't want to point in the wrong direction without something solid to count on.

@jeysal you are right of course! The thing is our tests freeze in the middle of running since (I assume and could be wrong) we run out of memory. After spending a lot of time trying to figure this out, I found #7274. It seemed to me from the discussion that the behaviour I encountered here is not intended. wdyt @SimenB ?

@javinor
Copy link
Contributor Author

javinor commented Feb 22, 2019

Bueller?

@alfaproject
Copy link

My tests are also leaking massively on CI but the exact same setup locally doesn't really leak (much at least).

It's so bad, I'm considering disabling tests on CI until I can make sense of what the difference is beside the OS. ):

@javinor
Copy link
Contributor Author

javinor commented Mar 25, 2019

Hey guys!

I simplified the memory leak case to a single file which runs tautological tests and eventually throws an exception due to a memory leak.

I'm not sure how to move forward with this... help? @SimenB @jeysal @milesj

[email protected] test /Users/javinor/workspace/jest-memory-leak
> jest --logHeapUsage --runInBand --config=jest.config.js


 RUNS  __test__/repeat100.test.js

<--- Last few GCs --->

[82597:0x103800000]    79124 ms: Mark-sweep 1259.1 (1442.2) -> 1240.0 (1436.2) MB, 438.3 / 0.0 ms  (average mu = 0.310, current mu = 0.304) allocation failure scavenge might not succeed
[82597:0x103800000]    79197 ms: Scavenge 1255.7 (1436.2) -> 1242.6 (1438.2) MB, 15.9 / 0.0 ms  (average mu = 0.310, current mu = 0.304) allocation failure
[82597:0x103800000]    79256 ms: Scavenge 1256.5 (1438.2) -> 1244.7 (1441.7) MB, 11.0 / 0.0 ms  (average mu = 0.310, current mu = 0.304) allocation failure


<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x2440d84dbe3d]
Security context: 0x30802859e6e9 <JSObject>
    1: prepareStackTrace [0x3080c9459f79] [/Users/javinor/workspace/garbage/jest_leak/node_modules/source-map-support/source-map-support.js:~388] [pc=0x2440d854b545](this=0x308094d07b59 <JSFunction Error (sfi = 0x308018616e01)>,error=0x3080e18623f9 <Error map = 0x3080f3c619f9>,stack=0x3080e1862e91 <JSArray[23]>)
    2: InternalFrame [pc: 0x2440d848ee75]
    ...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x10003c597 node::Abort() [/Users/javinor/.nvm/versions/node/v10.15.3/bin/node]
 2: 0x10003c7a1 node::OnFatalError(char const*, char const*) [/Users/javinor/.nvm/versions/node/v10.15.3/bin/node]
 3: 0x1001ad575 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/javinor/.nvm/versions/node/v10.15.3/bin/node]
 4: 0x100579242 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/javinor/.nvm/versions/node/v10.15.3/bin/node]
 5: 0x10057bd15 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/Users/javinor/.nvm/versions/node/v10.15.3/bin/node]
 6: 0x100577bbf v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/Users/javinor/.nvm/versions/node/v10.15.3/bin/node]
 7: 0x100575d94 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/javinor/.nvm/versions/node/v10.15.3/bin/node]
 8: 0x10058262c v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/Users/javinor/.nvm/versions/node/v10.15.3/bin/node]
 9: 0x1005826af v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/Users/javinor/.nvm/versions/node/v10.15.3/bin/node]
10: 0x100551ff4 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/Users/javinor/.nvm/versions/node/v10.15.3/bin/node]
11: 0x1007da044 v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/Users/javinor/.nvm/versions/node/v10.15.3/bin/node]
12: 0x2440d84dbe3d
Abort trap: 6

@fyodorvi
Copy link

Similar here, jest + ts-jest, simple tests get over 1GB of memory and eventually crash.

@kirillgroshkov
Copy link

crashes for us too

@jeysal
Copy link
Contributor

jeysal commented Mar 30, 2019

@javinor For a test file containing a ridiculous number of tests, I'm not sure there's much we can do, we have to keep the test objects around until the test file is finished - this is the heap while the tests are running:
image
Hundreds of MBs of test objects, so for the case shown in this repro we can't really help either :/

@thymikee
Copy link
Collaborator

FYI @scotthovestadt is currently working on holistically improving memory efficiency of Jest, so improvements are coming (some of them in the next minor version).

@kirillgroshkov
Copy link

I wonder, why isn't it possible for Jest to spawn a process for each test file, which will guarantee that memory will be freed? Ok, it can be slower, of course, but in my case - it's much better to be slower rather than get a crash from out-of-memory and be blocked to use Jest alltogether...

Maybe an option? Or a separate "runner" (not sure if I understand architecture and terminology right)?

Is it architecturally possible?

Or, will Node-experimental-workers solve it?..

@scotthovestadt
Copy link
Contributor

I've made a few improvements to memory in the next release:
#8234
#8233

I have a future plan to improve memory in a couple of ways:

  • by not holding onto test results at all, which are currently held until the end. related: Support JSON line output. #8242
  • limiting number of modules that can exist in the require cache

The problem with your suggestion of just spawning a new worker for each test is that it would be very slow. A better suggestion along the same lines would be to monitor the memory usage of the processes and auto-restart them at some threshold. I have some concerns about that in general, I'd rather always fix memory leaks than paper them over, but if a PR did that I would accept it.

Let me know if the release next week helps with the problems you've been experiencing.

@kirillgroshkov
Copy link

@scotthovestadt thanks for the info! I'll definitely check with the next release.

My actual issue is reported here: #8247
And there I'm dealing with much bigger leaks, +30Mb per each test file (~150 files in my project).

@javinor
Copy link
Contributor Author

javinor commented Apr 1, 2019

Thanks for the responses guys!

I think I can break this down to different two problems:

  1. Memory consumption grows the more test files I have
  2. Memory consumption grows the more tests I have per file

We're running thousands of tests, each creating a relatively big setup so we get bitten twice.

The original screenshot showing the consumption growing from test file to test file, hinting to a leak between tests - I have a few guesses as to why this happens, but nothing solid yet.

The exception I referred to later, as far as I can tell, really has to do with what @jeysal pointed out - having a large number of tests in the file. In our case, we have only hundreds of tests but with a very large setup. I'll try to provide a better reproduction of this.

I'll update after the next release, when I get to poke around a bit more and see the additional fixes in action. Thanks guys!

@alfaproject
Copy link

There must be something else wrong because I'm currently using Jest v23.6 and everything works fine, no memory leaks, no anything.

If I upgrade to latest Jest then the memory leaks start to happen, but only on the GiLab CI runner. Works fine locally.

@SimenB
Copy link
Member

SimenB commented Apr 2, 2019

@alfaproject
Copy link

Meh, it's still leaking in my setup ):

�[0KRunning with gitlab-runner 11.8.0 (4745a6f3)
�[0;m�[0K  on the-mill-ec2-gitlab-runner GvW8cLGR
�[0;m�[0KUsing Docker executor with image cypress/base:8 ...
�[0;m�[0KUsing locally found image version due to if-not-present pull policy
�[0;m�[0KUsing docker image sha256:2ad7a04a3a1d41fac2585d88e2dbd19ed3df9c57df2b27276c30e4f317c2c8e3 for cypress/base:8 ...
�[0;msection_start:1554216455:prepare_script
�[0KRunning on runner-GvW8cLGR-project-10463077-concurrent-0 via runner-gvw8clgr-gitlab-runner-1554212599-0c63c2c8...
section_end:1554216456:prepare_script
�[0Ksection_start:1554216456:get_sources
�[0K�[32;1mCloning repository...�[0;m
Cloning into '/builds/the-mill/lambda-gaming'...
�[32;1mChecking out a592f4d2 as update-fe-bo-packages...�[0;m
�[32;1mSkipping Git submodules setup�[0;m
section_end:1554216459:get_sources
�[0Ksection_start:1554216459:restore_cache
�[0Ksection_end:1554216460:restore_cache
�[0Ksection_start:1554216460:download_artifacts
�[0K�[32;1mDownloading artifacts for nodeModulesFe (189107055)...�[0;m
Downloading artifacts from coordinator... ok      �[0;m  id�[0;m=189107055 responseStatus�[0;m=200 OK token�[0;m=iQz-3io7
section_end:1554216481:download_artifacts
�[0Ksection_start:1554216481:build_script
�[0K�[32;1m$ cd ./packages/frontends�[0;m
�[32;1m$ node --version�[0;m
v8.12.0
�[32;1m$ node --expose-gc ./node_modules/.bin/ng test --ci --code-coverage=false --run-in-band�[0;m
PASS apps/whitelabel/src/app/app.component.spec.ts (195 MB heap size)
  AppComponent
    ✓ should create the app (87ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        5.168s
Ran all test suites.
PASS apps/backoffice/src/app/layout/layout.component.spec.ts (294 MB heap size)
PASS apps/backoffice/src/app/app.component.spec.ts (289 MB heap size)

Test Suites: 2 passed, 2 total
Tests:       3 passed, 3 total
Snapshots:   1 passed, 1 total
Time:        4.154s
Ran all test suites.
PASS libs/api/src/lib/api.module.spec.ts (364 MB heap size)
  ApiModule
    ✓ should create (69ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        3.283s
Ran all test suites.
PASS libs/core/src/lib/user.service.spec.ts (427 MB heap size)
PASS libs/core/src/lib/auth.service.spec.ts (426 MB heap size)
PASS libs/core/src/lib/wallet.service.spec.ts (426 MB heap size)
PASS libs/core/src/lib/unauth.guard.spec.ts (428 MB heap size)
PASS libs/core/src/lib/auth.guard.spec.ts (428 MB heap size)
PASS libs/core/src/lib/route.service.spec.ts (426 MB heap size)
PASS libs/core/src/lib/core.module.spec.ts (426 MB heap size)

Test Suites: 7 passed, 7 total
Tests:       8 passed, 8 total
Snapshots:   0 total
Time:        6.945s
Ran all test suites.
PASS libs/ui/src/lib/form-errors/form-errors.component.spec.ts (507 MB heap size)
PASS libs/ui/src/lib/loader/loader.component.spec.ts (507 MB heap size)
PASS libs/ui/src/lib/css-url.pipe.spec.ts (506 MB heap size)
PASS libs/ui/src/lib/ui.module.spec.ts (526 MB heap size)

Test Suites: 4 passed, 4 total
Tests:       6 passed, 6 total
Snapshots:   2 passed, 2 total
Time:        6.525s
Ran all test suites.
PASS libs/registration/src/lib/registration-form/registration-form.component.spec.ts (5.068s, 633 MB heap size)
PASS libs/registration/src/lib/registration.module.spec.ts (628 MB heap size)

Test Suites: 2 passed, 2 total
Tests:       3 passed, 3 total
Snapshots:   1 passed, 1 total
Time:        7.861s
Ran all test suites.
PASS libs/casino-game/src/lib/casino-game/casino-game.component.spec.ts (687 MB heap size)
PASS libs/casino-game/src/lib/casino-game.module.spec.ts (685 MB heap size)

Test Suites: 2 passed, 2 total
Tests:       4 passed, 4 total
Snapshots:   1 passed, 1 total
Time:        3.839s
Ran all test suites.
PASS libs/documents/src/lib/document-upload-form/document-upload-form.component.spec.ts (736 MB heap size)
PASS libs/documents/src/lib/documents/documents.component.spec.ts (736 MB heap size)
PASS libs/documents/src/lib/documents.module.spec.ts (736 MB heap size)

Test Suites: 3 passed, 3 total
Tests:       5 passed, 5 total
Snapshots:   2 passed, 2 total
Time:        4.32s
Ran all test suites.
PASS libs/forgot-password/src/lib/forgot-password-form/forgot-password-form.component.spec.ts (818 MB heap size)
PASS libs/forgot-password/src/lib/forgot-password/forgot-password.component.spec.ts (818 MB heap size)
PASS libs/forgot-password/src/lib/forgot-password.module.spec.ts (837 MB heap size)

Test Suites: 3 passed, 3 total
Tests:       5 passed, 5 total
Snapshots:   2 passed, 2 total
Time:        7.06s
Ran all test suites.
PASS libs/reset-password/src/lib/reset-password-form/reset-password-form.component.spec.ts (922 MB heap size)
PASS libs/reset-password/src/lib/reset-password/reset-password.component.spec.ts (919 MB heap size)
PASS libs/reset-password/src/lib/reset-password.module.spec.ts (929 MB heap size)

Test Suites: 3 passed, 3 total
Tests:       5 passed, 5 total
Snapshots:   2 passed, 2 total
Time:        7.922s
Ran all test suites.
PASS libs/payment/src/lib/payment-process/payment-process.component.spec.ts (1018 MB heap size)
PASS libs/payment/src/lib/payment-option-list/payment-option-list.component.spec.ts (1016 MB heap size)
PASS libs/payment/src/lib/payment-option/payment-option.component.spec.ts (1011 MB heap size)
PASS libs/payment/src/lib/card-form/card-form.component.spec.ts (1013 MB heap size)
PASS libs/payment/src/lib/payment.service.spec.ts (1013 MB heap size)
PASS libs/payment/src/lib/payment.module.spec.ts (1032 MB heap size)
PASS libs/payment/src/lib/card-type-detector.directive.spec.ts (1023 MB heap size)

Test Suites: 7 passed, 7 total
Tests:       11 passed, 11 total
Snapshots:   4 passed, 4 total
Time:        14.741s
Ran all test suites.
PASS libs/fluid-container/src/lib/fluid-container/fluid-container.component.spec.ts (1081 MB heap size)
PASS libs/fluid-container/src/lib/fluid-container.module.spec.ts (1081 MB heap size)

Test Suites: 2 passed, 2 total
Tests:       3 passed, 3 total
Snapshots:   1 passed, 1 total
Time:        4.164s
Ran all test suites.
PASS libs/layout/src/lib/layout/layout.component.spec.ts (6.025s, 1181 MB heap size)
FAIL libs/layout/src/lib/sidebar/sidebar.component.spec.ts
  ● Test suite failed to run

    TypeScript diagnostics (customize using `[jest-config].globals.ts-jest.diagnostics` option):
    �[96mlibs/layout/src/lib/sidebar/sidebar.component.spec.ts�[0m:�[93m26�[0m:�[93m7�[0m - �[91merror�[0m�[90m TS2739: �[0mType '{ __typename: "NavList"; classes: string[]; navListItems: undefined[]; }' is missing the following properties from type 'NavList': horizontal, id

    �[7m26�[0m       navList: {
    �[7m  �[0m �[91m      ~~~~~~~�[0m

      �[96mlibs/layout/src/lib/sidebar/sidebar.graphql.ts�[0m:�[93m8�[0m:�[93m3�[0m
        �[7m8�[0m   navList: NavList;
        �[7m �[0m �[96m  ~~~~~~~�[0m
        The expected type comes from property 'navList' which is declared here on type 'Sidebar'

PASS libs/layout/src/lib/header/header.component.spec.ts (1213 MB heap size)
PASS libs/layout/src/lib/footer/footer.component.spec.ts (1194 MB heap size)
PASS libs/layout/src/lib/layout.module.spec.ts (5.055s, 1212 MB heap size)

Test Suites: 1 failed, 4 passed, 5 total
Tests:       7 passed, 7 total
Snapshots:   3 passed, 3 total
Time:        19.157s
Ran all test suites.
PASS libs/cms/src/lib/page/page.component.spec.ts (7.531s, 1269 MB heap size)
PASS libs/cms/src/lib/dialog-route/dialog-route.component.spec.ts (1271 MB heap size)
PASS libs/cms/src/lib/content-group/content-group.component.spec.ts (1272 MB heap size)
PASS libs/cms/src/lib/cms.service.spec.ts (1270 MB heap size)
PASS libs/cms/src/lib/slot.directive.spec.ts (1268 MB heap size)
PASS libs/cms/src/lib/cms.module.spec.ts (1270 MB heap size)

Test Suites: 6 passed, 6 total
Tests:       9 passed, 9 total
Snapshots:   3 passed, 3 total
Time:        18.367s
Ran all test suites.
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

<--- Last few GCs --->

[10:0x2510510]   136242 ms: Mark-sweep 1362.8 (1460.0) -> 1362.8 (1460.0) MB, 1827.9 / 0.1 ms  allocation failure GC in old space requested
[10:0x2510510]   137760 ms: Mark-sweep 1362.8 (1460.0) -> 1362.8 (1429.0) MB, 1518.2 / 0.1 ms  last resort GC in old space requested
[10:0x2510510]   139285 ms: Mark-sweep 1362.8 (1429.0) -> 1362.8 (1429.0) MB, 1524.6 / 0.1 ms  last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0xb1cf5fa5879 <JSObject>
    1: stringSlice(aka stringSlice) [buffer.js:560] [bytecode=0x1e161b35dd29 offset=94](this=0x11a4d26822d1 <undefined>,buf=0x20928062d71 <Uint8Array map = 0x35a39b242941>,encoding=0xb1cf5fb5409 <String[4]: utf8>,start=0,end=1097377)
    2: toString [buffer.js:633] [bytecode=0x1e161b35d979 offset=145](this=0x20928062d71 <Uint8Array map = 0x35a39b242941>,encoding=0xb1cf5fb5409 <String[4]: utf8>,st...

 1: node::Abort() [ng test --ci --code-coverage=false --run-in-band]
 2: 0x8cbf4c [ng test --ci --code-coverage=false --run-in-band]
 3: v8::Utils::ReportOOMFailure(char const*, bool) [ng test --ci --code-coverage=false --run-in-band]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [ng test --ci --code-coverage=false --run-in-band]
 5: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [ng test --ci --code-coverage=false --run-in-band]
 6: v8::internal::Factory::NewStringFromUtf8(v8::internal::Vector<char const>, v8::internal::PretenureFlag) [ng test --ci --code-coverage=false --run-in-band]
 7: v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::NewStringType, int) [ng test --ci --code-coverage=false --run-in-band]
 8: node::StringBytes::Encode(v8::Isolate*, char const*, unsigned long, node::encoding, v8::Local<v8::Value>*) [ng test --ci --code-coverage=false --run-in-band]
 9: 0x8e4a76 [ng test --ci --code-coverage=false --run-in-band]
10: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [ng test --ci --code-coverage=false --run-in-band]
11: 0xb0bbec [ng test --ci --code-coverage=false --run-in-band]
12: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [ng test --ci --code-coverage=false --run-in-band]
13: 0x220bb08042fd
/bin/bash: line 90:    10 Aborted                 (core dumped) node --expose-gc ./node_modules/.bin/ng test --ci --code-coverage=false --run-in-band
section_end:1554216631:build_script
�[0Ksection_start:1554216631:after_script
�[0Ksection_end:1554216633:after_script
�[0Ksection_start:1554216633:upload_artifacts_on_failure
�[0K�[32;1mUploading artifacts...�[0;m
�[0;33mWARNING: ./packages/frontends/junit/*.xml: no matching files�[0;m 
�[31;1mERROR: No files to upload                         �[0;m 
section_end:1554216634:upload_artifacts_on_failure
�[0K�[31;1mERROR: Job failed: exit code 1
�[0;m

@peterdemartini
Copy link

peterdemartini commented Apr 5, 2019

After updating to 24.6.0, we are seeing the similar issue running our CI tests. When logging the heap usage, we see an increase of memory usage after each test file.

@scotthovestadt
Copy link
Contributor

This should help: #8282

Will be released soon.

@alfaproject
Copy link

How soon? )':

@Supernats
Copy link

For those reading along at home, this went out in 24.8.0.

@unional
Copy link
Contributor

unional commented Jul 18, 2019

The problem with your suggestion of just spawning a new worker for each test is that it would be very slow.

This would also be a huge breaking change.

@unional
Copy link
Contributor

unional commented Jul 18, 2019

If I upgrade to latest Jest then the memory leaks start to happen, but only on the GiLab CI runner. Works fine locally.

Also encounter out of memory issue with jest + ts-jest:
https://circleci.com/gh/unional/standard-log/382

Originally I thought it was some circular dependency on my source code, but may be jest related.
So throwing this into the mix. 🌷

@Supernats
Copy link

Supernats commented Jul 18, 2019

@unional if you're on Circle, make sure maxWorkers isn't higher than the CPU allotted you by Circle.

EDIT: To be clear, you should proactively specify maxWorkers at or below the CPU allotted you Circle.

@unional
Copy link
Contributor

unional commented Jul 18, 2019

@Supernats thanks. I think I did have that set during the failure, currently I'm running it with --runInBand 😢

But it still fail once in a while:
https://circleci.com/gh/unional/standard-log/448

@ulrichb
Copy link
Contributor

ulrichb commented Jul 29, 2019

I have Jest 24.8.0 and #8282 doesn't seem to help. Also --runInBand only helps a bit (4 GB instead of 10 GB 😮).

Pleaaaaaaase fix this ...

@kirillgroshkov
Copy link

Yes, following this thread for long since it still fails for us and in ~10% of the cases runs with "out of memory" for CircleCI 2Gb RAM instances.

@chrisandrewcl
Copy link

I've run some tests considering various configurations. Hope it helps someone.

node version node args jest args custom behavior time (seconds) heap (mb)
16.10 --expose-gc --no-compilation-cache --maxWorkers 1 afterAll(global.gc) + force options.serial to false on jest-runner 303 45
16.18 --expose-gc --no-compilation-cache --maxWorkers 1 afterAll(global.gc) + force options.serial to false on jest-runner 325 47
16.10 --expose-gc --no-compilation-cache --maxWorkers 2 - 236 64
16.18 --expose-gc --no-compilation-cache --maxWorkers 2 - 167 67
16.10 --expose-gc --maxWorkers 1 afterAll(global.gc) + force options.serial to false on jest-runner 234 82
16.10 --expose-gc --maxWorkers 2 - 155 96
16.10 --expose-gc --no-compilation-cache --runInBand --detectLeaks afterAll(global.gc) 313 159
16.10 --expose-gc --no-compilation-cache --runInBand --detectLeaks - 307 160
16.10 --expose-gc --no-compilation-cache --runInBand - 313 160
16.10 --expose-gc --no-compilation-cache --maxWorkers 1 - 333 160
16.10 --expose-gc --no-compilation-cache --runInBand --detectLeaks afterEach(global.gc) 397 160
16.18 --expose-gc --no-compilation-cache --runInBand --detectLeaks afterAll(global.gc) 281 164
16.18 --expose-gc --no-compilation-cache --runInBand --detectLeaks afterEach(global.gc) 298 164
16.18 --expose-gc --no-compilation-cache --maxWorkers 1 - 287 165
16.18 --expose-gc --no-compilation-cache --runInBand --detectLeaks - 300 165
16.18 --expose-gc --no-compilation-cache --runInBand - 337 165
16.10 --expose-gc --runInBand --detectLeaks - 258 199
16.10 --expose-gc --runInBand - 247 201
16.10 --expose-gc --maxWorkers 2 - 286 201
16.10 --expose-gc --runInBand --detectLeaks afterAll(global.gc) 256 202
16.10 --expose-gc --runInBand --detectLeaks afterEach(global.gc) 309 206
16.10   --runInBand - 261 629
16.18 --expose-gc --maxWorkers 2 - 277 899
16.18 --no-compilation-cache --runInBand - 297 907
16.18   --runInBand - 281 1055
16.18 --expose-gc --runInBand - 347 1262
16.18 --expose-gc --maxWorkers 1 afterAll(global.gc) + force options.serial to false on jest-runner 337 1380
Test Suites: 3 skipped, 31 passed, 31 of 34 total
Tests:       20 skipped, 49 todo, 171 passed, 240 total
Snapshots:   0 total

* Running with Jest 29.2.2 on a bitbucket pipeline container using node official docker images

ramontayag added a commit to swan-bitcoin/node-marketo that referenced this issue Feb 1, 2023
Versions of Axios 1.x are causing issues with
Jest (axios/axios#5101).

Jest 28 and 29, where this issue is resolved, has other
issues surrounding memory leaks
(jestjs/jest#7874).

Allow `>=0.25.0` for applications that cannot upgrade Jest
at this moment.
@wyardley
Copy link

wyardley commented Mar 8, 2023

From a preliminary run or two, it looks to me like going back to 16.10 is resolving these errors for us as well.
Is there any more clarity on why this is, or what a real fix might look like?

@StringEpsilon
Copy link
Contributor

Is there any more clarity on why this is, or what a real fix might look like?

All the info on the regression that specifically affects node >= 16.11 is found in this issue: #11956

@earloc
Copy link

earloc commented Feb 9, 2024

Just spend about 2 days figuring out how to overcome this, until I discovered #11956.

TLDR; regression introduced in node 16.11, fixed in 21.1.
Backporting Bugfix for node 18 seems to be on the way, see
#11956 (comment)

@MattLishmanYara
Copy link

Just spend about 2 days figuring out how to overcome this, until I discovered #11956.

TLDR; regression introduced in node 16.11, fixed in 21.1. Backporting Bugfix for node 18 seems to be on the way, see #11956 (comment)

In case anyone stumbles across this and wants a simple solution, node 20.10.0 contains a fix for this.
Upgrading to node 20.10.0 solved this for me 🎉

@earloc
Copy link

earloc commented Feb 9, 2024

Reading the linked issue, it says '21.1', but might as well being already backported to '20.x', leaving '18.x' to be waiting for a fix🤷.

For our team, switching our ci-builds to '21.x' did the deal, even if this might introduce runtime-confusion 😉.

@eyalroth
Copy link
Contributor

eyalroth commented Jul 28, 2024

I'm currently investigating memory leaks in Jest (after #11956 solution), so I was interested in this case.

I followed these steps:

  1. Clone the reproduction repo.
  2. rm package-lock.json (outdated npm version)
  3. npm install
  4. Clone Jest main and build it
  5. Add .nvmrc with 20.14.0
  6. Edit runTest.ts in jest-runner to point to the project own jest-environment-node (instead of the default target repo)
  7. Run jest with this script in jest-cli:
node ./bin/jest.js -c /repos/jest-memory-leak/jest.config.js --runInBand --logHeapUsage

The initial execution of the 30 test files barely reached 100MB at the last file, so I added more duplicates, totaling in 651 files.

The tests slowly reached a close to 1GB heap size, but just before that, the heap was cleaned back to minimum (56MB):

Results
.nvm/versions/node/v20.14.0/bin/yarn run jest:repro
 PASS  ../../../jest-memory-leak/__test__/repeat118_5.test.js (36 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_9.test.js (29 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_13.test.js (36 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_7.test.js (42 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_4.test.js (34 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_14.test.js (40 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_14.test.js (46 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_2.test.js (51 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_5.test.js (43 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_1.test.js (49 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_3.test.js (55 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_3.test.js (41 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_17.test.js (47 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_4.test.js (52 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_2.test.js (58 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_13.test.js (51 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_1.test.js (57 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_6.test.js (62 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_18.test.js (68 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_5.test.js (60 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_6.test.js (66 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_19.test.js (71 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_2.test.js (77 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_2.test.js (69 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_16.test.js (75 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_4.test.js (80 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_12.test.js (86 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_13.test.js (79 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_15.test.js (84 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110.test.js (90 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_18.test.js (95 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_4.test.js (88 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_8.test.js (93 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_3.test.js (99 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_5.test.js (104 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_13.test.js (97 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_15.test.js (103 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_5.test.js (108 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_12.test.js (114 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_3.test.js (107 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_4.test.js (112 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_5.test.js (117 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_17.test.js (123 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_7.test.js (116 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_4.test.js (121 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_1.test.js (127 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120.test.js (132 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_5.test.js (125 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_19.test.js (131 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_5.test.js (136 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_5.test.js (142 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_5.test.js (135 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_2.test.js (140 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_17.test.js (146 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_3.test.js (151 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_1.test.js (144 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105.test.js (149 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_8.test.js (155 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_18.test.js (160 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_5.test.js (153 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_4.test.js (81 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_2.test.js (87 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_13.test.js (92 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_5.test.js (97 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_2.test.js (91 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_16.test.js (96 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_11.test.js (102 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_1.test.js (107 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_6.test.js (100 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_19.test.js (106 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_6.test.js (111 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_17.test.js (116 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_16.test.js (109 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_4.test.js (115 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_2.test.js (120 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_2.test.js (126 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_2.test.js (119 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_14.test.js (124 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_13.test.js (130 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_1.test.js (135 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_2.test.js (128 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_12.test.js (133 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_17.test.js (139 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_16.test.js (144 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_16.test.js (137 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_5.test.js (143 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_12.test.js (148 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_15.test.js (154 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_13.test.js (147 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_18.test.js (152 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_1.test.js (158 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_11.test.js (163 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_5.test.js (156 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_20.test.js (161 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109.test.js (167 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_2.test.js (172 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_15.test.js (165 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_14.test.js (171 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_14.test.js (176 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_13.test.js (181 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_10.test.js (175 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_1.test.js (180 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_6.test.js (185 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_15.test.js (191 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_5.test.js (184 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_4.test.js (189 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_14.test.js (195 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_19.test.js (200 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_12.test.js (193 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_3.test.js (198 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_20.test.js (204 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_18.test.js (209 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_17.test.js (202 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_1.test.js (208 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_3.test.js (213 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_15.test.js (219 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_4.test.js (212 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127.test.js (217 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_1.test.js (222 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_14.test.js (228 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_6.test.js (221 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_7.test.js (226 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_4.test.js (232 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_6.test.js (237 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_2.test.js (230 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_15.test.js (236 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_11.test.js (241 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_10.test.js (247 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_1.test.js (240 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_9.test.js (245 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_3.test.js (250 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_17.test.js (256 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_14.test.js (249 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_2.test.js (254 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_8.test.js (260 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_7.test.js (265 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_4.test.js (258 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_19.test.js (264 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_15.test.js (269 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_9.test.js (274 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_8.test.js (267 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_4.test.js (273 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_5.test.js (278 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_20.test.js (284 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_17.test.js (277 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_9.test.js (282 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_8.test.js (287 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_5.test.js (293 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_3.test.js (286 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_20.test.js (291 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_16.test.js (297 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_13.test.js (302 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_12.test.js (295 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_11.test.js (301 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_7.test.js (306 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_20.test.js (311 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_13.test.js (304 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_10.test.js (310 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_9.test.js (315 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_7.test.js (321 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_15.test.js (178 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_13.test.js (183 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_7.test.js (189 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_4.test.js (194 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_12.test.js (187 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_10.test.js (193 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_8.test.js (198 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_7.test.js (204 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_3.test.js (197 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_11.test.js (202 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_9.test.js (207 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_7.test.js (213 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_4.test.js (206 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_3.test.js (211 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_18.test.js (217 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_14.test.js (222 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_13.test.js (215 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_3.test.js (221 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_2.test.js (226 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_14.test.js (231 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_1.test.js (224 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_5.test.js (230 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_3.test.js (235 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_10.test.js (241 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_8.test.js (234 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_7.test.js (239 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_14.test.js (245 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_1.test.js (250 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_13.test.js (243 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_16.test.js (249 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_11.test.js (254 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_6.test.js (259 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_3.test.js (252 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_20.test.js (258 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_19.test.js (263 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_16.test.js (268 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_18.test.js (262 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_6.test.js (267 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_20.test.js (272 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_15.test.js (278 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_14.test.js (271 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_7.test.js (276 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_6.test.js (282 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_20.test.js (287 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_18.test.js (280 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_16.test.js (286 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_15.test.js (291 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_13.test.js (297 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_10.test.js (290 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_20.test.js (295 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_5.test.js (301 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_11.test.js (306 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_10.test.js (299 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_9.test.js (304 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_6.test.js (310 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_20.test.js (315 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_2.test.js (308 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_18.test.js (314 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_17.test.js (319 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_14.test.js (324 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_12.test.js (317 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_10.test.js (323 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_9.test.js (328 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_6.test.js (334 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_19.test.js (327 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_18.test.js (332 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_7.test.js (337 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_6.test.js (343 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_4.test.js (336 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_19.test.js (341 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_13.test.js (347 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_12.test.js (352 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_10.test.js (345 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_1.test.js (350 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_6.test.js (356 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_19.test.js (361 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_15.test.js (355 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_8.test.js (360 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_5.test.js (366 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_20.test.js (371 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_3.test.js (364 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_19.test.js (369 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_1.test.js (375 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_2.test.js (380 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_18.test.js (373 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_17.test.js (378 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_15.test.js (384 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_11.test.js (389 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_9.test.js (382 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_15.test.js (388 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_14.test.js (393 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_12.test.js (398 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_6.test.js (391 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_3.test.js (397 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_20.test.js (402 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_8.test.js (408 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_2.test.js (401 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_19.test.js (406 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_16.test.js (412 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_20.test.js (417 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_2.test.js (410 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_17.test.js (415 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_15.test.js (421 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_13.test.js (426 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_10.test.js (419 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_2.test.js (425 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_10.test.js (430 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_19.test.js (436 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_16.test.js (428 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_4.test.js (434 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_20.test.js (440 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_16.test.js (445 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_13.test.js (438 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_11.test.js (443 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_10.test.js (449 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_12.test.js (454 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_1.test.js (447 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_19.test.js (453 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_17.test.js (458 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_14.test.js (463 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_11.test.js (456 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_9.test.js (462 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_2.test.js (467 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_19.test.js (473 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_18.test.js (466 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_16.test.js (471 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_6.test.js (477 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_20.test.js (482 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_15.test.js (475 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_4.test.js (480 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_9.test.js (486 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_8.test.js (491 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_16.test.js (484 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_13.test.js (490 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_12.test.js (495 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_11.test.js (501 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_1.test.js (494 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_8.test.js (499 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_6.test.js (504 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_20.test.js (510 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_16.test.js (503 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_20.test.js (508 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_18.test.js (514 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_17.test.js (519 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_10.test.js (512 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_4.test.js (518 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_13.test.js (523 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_6.test.js (528 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_20.test.js (521 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_19.test.js (527 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_17.test.js (532 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_15.test.js (538 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_11.test.js (531 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_8.test.js (536 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_7.test.js (542 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_13.test.js (547 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_8.test.js (540 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_14.test.js (545 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_11.test.js (551 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114.test.js (556 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_9.test.js (549 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_8.test.js (555 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_6.test.js (560 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_19.test.js (565 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_16.test.js (559 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_15.test.js (564 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_14.test.js (569 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_12.test.js (575 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_20.test.js (568 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_2.test.js (573 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_18.test.js (578 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_17.test.js (584 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_14.test.js (577 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_12.test.js (582 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_10.test.js (588 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_5.test.js (593 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_3.test.js (587 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_14.test.js (592 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_1.test.js (597 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_8.test.js (603 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_3.test.js (596 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_2.test.js (601 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_14.test.js (606 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_11.test.js (612 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_2.test.js (605 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_17.test.js (610 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_12.test.js (616 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_7.test.js (621 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_18.test.js (614 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_13.test.js (620 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_10.test.js (625 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_7.test.js (630 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_3.test.js (624 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_19.test.js (629 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_11.test.js (634 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_19.test.js (640 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_17.test.js (633 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_16.test.js (638 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_12.test.js (643 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_11.test.js (649 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_9.test.js (642 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_3.test.js (647 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_20.test.js (653 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_18.test.js (658 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_9.test.js (651 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_1.test.js (657 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_8.test.js (662 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_20.test.js (667 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_15.test.js (660 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_10.test.js (666 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_1.test.js (671 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_7.test.js (677 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_6.test.js (670 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_18.test.js (675 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_17.test.js (681 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_16.test.js (686 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_14.test.js (679 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_11.test.js (684 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_10.test.js (690 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_9.test.js (695 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_8.test.js (688 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_7.test.js (694 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_6.test.js (699 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_20.test.js (705 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_19.test.js (698 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_18.test.js (703 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_6.test.js (380 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_20.test.js (386 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_15.test.js (391 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_6.test.js (396 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_4.test.js (401 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_3.test.js (392 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_20.test.js (398 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_14.test.js (403 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_11.test.js (409 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_6.test.js (401 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_18.test.js (407 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_11.test.js (412 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_10.test.js (417 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_9.test.js (410 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_16.test.js (416 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_12.test.js (421 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_1.test.js (427 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_16.test.js (420 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_12.test.js (425 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_11.test.js (430 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_10.test.js (436 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_7.test.js (429 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_17.test.js (434 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_15.test.js (440 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_14.test.js (445 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_10.test.js (438 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_9.test.js (444 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_19.test.js (449 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_8.test.js (455 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_20.test.js (448 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_19.test.js (453 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_18.test.js (459 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_15.test.js (464 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_14.test.js (457 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_11.test.js (462 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_10.test.js (468 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_9.test.js (473 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_8.test.js (466 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_7.test.js (472 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_19.test.js (477 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_15.test.js (482 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_9.test.js (475 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_7.test.js (481 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_18.test.js (486 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_12.test.js (492 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_9.test.js (485 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_8.test.js (490 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_7.test.js (496 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_5.test.js (501 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_14.test.js (494 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_12.test.js (500 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_10.test.js (505 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_18.test.js (510 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_12.test.js (503 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_19.test.js (509 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_7.test.js (514 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_3.test.js (519 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_18.test.js (512 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_17.test.js (518 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_12.test.js (523 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_11.test.js (529 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_8.test.js (522 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_7.test.js (527 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_20.test.js (533 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_19.test.js (538 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_16.test.js (531 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_3.test.js (536 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_16.test.js (542 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_19.test.js (547 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_16.test.js (540 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_13.test.js (546 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_11.test.js (551 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_8.test.js (556 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_13.test.js (550 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_11.test.js (555 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_10.test.js (560 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_9.test.js (566 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_16.test.js (559 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_7.test.js (564 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_4.test.js (570 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_10.test.js (575 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_9.test.js (568 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_16.test.js (573 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_8.test.js (579 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_6.test.js (584 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_12.test.js (577 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_8.test.js (583 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_2.test.js (588 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_18.test.js (593 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_14.test.js (587 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_5.test.js (592 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_16.test.js (597 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101_12.test.js (603 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_14.test.js (596 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_13.test.js (601 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_12.test.js (607 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_9.test.js (612 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_8.test.js (605 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_19.test.js (611 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_15.test.js (616 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_13.test.js (622 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129_12.test.js (615 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat129.test.js (620 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128_17.test.js (625 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_9.test.js (631 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_8.test.js (624 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_7.test.js (629 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_6.test.js (635 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_3.test.js (640 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_20.test.js (633 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_2.test.js (638 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_18.test.js (644 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_17.test.js (649 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_16.test.js (642 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_15.test.js (648 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_11.test.js (653 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_10.test.js (659 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_9.test.js (652 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_8.test.js (657 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_7.test.js (662 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_18.test.js (668 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_16.test.js (661 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_17.test.js (666 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_15.test.js (672 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_13.test.js (677 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_12.test.js (670 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_8.test.js (676 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_7.test.js (681 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_2.test.js (687 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_19.test.js (680 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_16.test.js (685 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_13.test.js (690 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_7.test.js (696 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_5.test.js (689 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_3.test.js (694 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_19.test.js (700 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_18.test.js (705 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_17.test.js (698 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_19.test.js (703 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_17.test.js (709 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_20.test.js (714 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_19.test.js (707 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_15.test.js (713 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_13.test.js (718 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_12.test.js (723 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_11.test.js (716 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_7.test.js (722 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_6.test.js (727 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_17.test.js (733 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_12.test.js (726 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_8.test.js (731 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_11.test.js (737 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_13.test.js (742 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116.test.js (735 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_9.test.js (741 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115_3.test.js (746 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_4.test.js (751 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_10.test.js (744 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_9.test.js (750 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_6.test.js (755 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_4.test.js (761 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_17.test.js (754 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112_13.test.js (759 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111_1.test.js (765 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat111.test.js (770 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_4.test.js (763 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_15.test.js (768 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat110_1.test.js (774 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_7.test.js (779 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_12.test.js (772 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108_15.test.js (778 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_18.test.js (783 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_14.test.js (789 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107.test.js (781 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_6.test.js (787 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_4.test.js (792 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106.test.js (798 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_9.test.js (791 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_16.test.js (796 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104.test.js (801 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_10.test.js (807 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_6.test.js (800 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102_17.test.js (805 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_11.test.js (811 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130_11.test.js (816 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat128.test.js (809 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_19.test.js (815 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat127_14.test.js (820 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126_1.test.js (826 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_10.test.js (819 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_9.test.js (824 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_4.test.js (829 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_20.test.js (835 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_17.test.js (828 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_15.test.js (833 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124.test.js (839 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_8.test.js (844 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_11.test.js (837 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_10.test.js (843 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_9.test.js (848 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_8.test.js (853 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_7.test.js (847 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_6.test.js (852 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_20.test.js (857 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_18.test.js (863 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121.test.js (856 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_18.test.js (861 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_17.test.js (866 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_14.test.js (872 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_10.test.js (865 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_9.test.js (870 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_16.test.js (876 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_13.test.js (881 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_1.test.js (874 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119.test.js (880 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118.test.js (885 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_14.test.js (890 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_10.test.js (884 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117.test.js (889 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_4.test.js (894 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_2.test.js (900 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat116_1.test.js (893 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat115.test.js (898 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat114_1.test.js (904 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat112.test.js (909 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat109_2.test.js (902 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat108.test.js (907 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat107_11.test.js (913 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat106_17.test.js (918 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat105_20.test.js (912 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_4.test.js (917 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103_5.test.js (922 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_15.test.js (928 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat130.test.js (921 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat126.test.js (926 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125_5.test.js (931 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_5.test.js (937 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_3.test.js (930 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat124_12.test.js (935 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123.test.js (941 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_5.test.js (946 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122.test.js (939 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_5.test.js (945 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_3.test.js (950 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_2.test.js (955 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat121_18.test.js (948 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat120_4.test.js (954 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_4.test.js (959 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_3.test.js (965 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat118_1.test.js (958 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_5.test.js (963 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat117_1.test.js (968 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_3.test.js (974 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat103.test.js (967 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat102.test.js (972 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat101.test.js (978 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat125.test.js (983 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat123_4.test.js (976 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat122_2.test.js (981 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat119_3.test.js (987 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113_1.test.js (992 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat113.test.js (984 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat104_1.test.js (56 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100_5.test.js (60 MB heap size)
 PASS  ../../../jest-memory-leak/__test__/repeat100.test.js (67 MB heap size)

Test Suites: 651 passed, 651 total
Tests:       65100 passed, 65100 total
Snapshots:   0 total
Time:        19.446 s
Ran all test suites.

Process finished with exit code 0

I think it's safe to conclude that the initial issue is resolved. It's not to say that there aren't memory leaks, but only that they are not reproducible using a simple repo.

For information on my progress with the other leaks, see #15215.

@akashgangrade
Copy link

adding workerIdleMemoryLimit: '1024MB', to the jest.config.js file resolved the issue for me.

@EduardoAC
Copy link

EduardoAC commented Aug 16, 2024

Do you know if we have an update on this? I face this problem while upgrading to Expo version 50 as we have a significant test set from which I have tests with a considerable heap size.

Example: VerifyMobileNumber.resendCode.test.tsx (9.593 s, 2355 MB heap size)

Current setup:
NodeJS: v20.16.0
Jest: 29.7.0
Jest-expo: 50.0.4
expo: 50.0.20

My current concerns:

  • workerIdleMemoryLimit is ignored with the heap size. Why is this? Could we limit memory usage in general
  • Not many resources to explore the root cause of the heap size

Update:
I have analysed one of the issues we were facing with a large memory heap; after some investigation, I decided to drop the fake timers, suspecting that they were the cause of the large heap size.

Original heap size with useFakeTimers RecoveryVerifyMobile.exceededAttempts.test.ts (11.134 s, 2582 MB heap size)
New heap size without useFakeTimers RecoveryVerifyMobile.exceededAttempts.test.ts (396 MB heap size)

describe("test", () => {
  beforeEach(async () => {
    jest.useFakeTimers();

    server.use( /* ... */);

    // Async code with awaits
  });

  afterEach(() => jest.runOnlyPendingTimers());

  it("test case", async () => {
    // Async code with awaits
  });
});

@CoryDanielson
Copy link

CoryDanielson commented Aug 27, 2024

Our setup is a bit over 3000 test files sharded across 8 or 12 jest shards. So we are running 250-400 tests in each shard. These run in parallel on shared hardware. Measuring performance is really difficult in this environment because the run times are so inconsistent. Our main concern was reducing memory usage, though.

We run our suite with:

  • node flags --expose-gc --max-old-space-size=4096
  • jest flags --cache --ci --logHeapUsage --maxWorkers=3

These are the additional settings that helped with memory.

  • workerIdleMemoryLimit='500mb'
    • This kept memory under 500mb. Love this setting.
  • workerThreads=true
    • Didn't see measurable improvement from this in run time, but it seems implied with workerIdleMemoryLimit so I kept it.
  • --max-semi-space-size=64
    • I saw ~7% improvement in run time locally on a suite that took 194s and then 181s to run. I assume/hope there is a benefit in CI too.
    • This setting allocates more memory for certain kinds of garbage that is cleaned up with frequent scavenge GC events. With more room for garbage, and less GC events, the tests are free to run uninterrupted for a longer time. The trade-off is that there will be more of the slower major GC events -- but -- when setting workerIdleMemoryLimit you're setting yourself up for more major GC events anyways... setting max-semi-space-size to 64 seems to be a nice optimization to pair with workerIdleMemoryLimit.
  • --max-old-space-size: Reduced down to --max-old-space-size=2048
    • (Edit: I have removed max-old-space-size from our config for simplicity, because it's basically unused)

Read more about max-semi-space-size

@EduardoAC
Copy link

@CoryDanielson, great shared. Nevertheless, I have used the commands you suggested, using 17 chunks concurrently with parallel running in each chunk. I noticed the issue generally came from how asynchronous code and memory allocation are done; as explained above, workerIdleMemoryLimit didn't change this fact or limit the heap memory usage.

Your other features are interesting, so I will try them next week and provide feedback. Do you use asynchronous testing syntax for your tests, and do you use Jest fake timers?

@CoryDanielson
Copy link

CoryDanielson commented Sep 10, 2024

@EduardoAC We have ~3100 test files.

  • ~500 files use async or await
  • only 6 use useFakeTimers.

I know run time is not really entirely related to memory, but our most problematic/flaky tests are component tests (react testing library) with lots of async calls, and a few that have large jest.setTimeout(60 * 1000) values.

Are you running 17 chunks often? We use --changedSince to reduce the number of tests that we run on pull requests. About half of our PRs run a single Jest shard, and the rest run 5 shards with 320 test files each.

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

No branches or pull requests