-
Notifications
You must be signed in to change notification settings - Fork 1k
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 with rw test web
when run sequentially - CI machines
#4569
Comments
This is excellent work @callingmedic911 Thank you! |
Hi @callingmedic911, I have been facing problems with memory heap on github actions, one of the solutions I found is importing the mocks only once under redwood/packages/testing/config/jest/web/jest.setup.js. instead of:
You can do:
Something else I found it's in my mac machine runs smoothly memory heap is stable, but on github actions ubuntu-latest consumes more memory 🤷🏽♂️, and finally NODE_OPTIONS: "--max_old_space_size=4096" is override by something in redwood cli. if you run |
How were you able to test that against your codebase? |
@ortegoncarlos thanks for sharing your finding in detail. I believe there's PR open recently to reduce bloat from mock #6281. @razzeee Using |
Thanks! I'm not convinced, this is CI specific. I'm also having this locally (fedora) and I think my colleague also sees it on mac os. This part is probably obsolete now, that you mention that PR, still doesn't hurt. I took https://github.com/redwoodjs/redwood-tutorial and run it with this:
Which returned:
So it's not enough to crash the process, but it still seems like way to much heap for those tests? |
Just to report, that after update with redwood 3.x the memory leaks went away. so this probably should be close |
#4208 had the changes to run web tests in parallel which reduced the frequency of leaks by running tests in parallel but in Github Action, where CPU is limited, the parallel execution is not always possible, which results in frequent crashes due to out of memory.
Here's an example repo: https://github.com/callingmedic911/rw-web-memory-leak with CI check which fails on the latest Node LTS (16.14). Heap usage is better with Node 16.10 but the leak is still visible and if we increase the number of tests + mocks it'll also crash with Node 16.10 or lower.
Example CI run: https://github.com/callingmedic911/rw-web-memory-leak/runs/5321129020
This leak is exacerbated due to jestjs/jest#11956 but since we're require-ing all of mock in the project for each unit test across all test files, it's causing massive heap usage:
redwood/packages/testing/config/jest/web/jest.setup.js
Lines 21 to 25 in 59d31b3
I think for the next steps, we can evaluate:
instead of importing all mocks for each test, if we can somehow require only required ones. The idea is to put the import statement for a mock file inside the corresponding cell, so even if we have nested cells, the corresponding mock file would be imported. A good place to validate this would be by modifying the "auto-mock" babel plugin to insert the import statement in cell.
expose-gc
and force gc after each test suite run.The text was updated successfully, but these errors were encountered: