Memory leak while using node 16 (but not 14)
See original GitHub issuePrerequisites
- I confirm my issue is not in the opened issues
- I confirm the Frequently Asked Questions didn’t contain the answer to my issue
Environment check
- I’m using the latest
msw
version - I’m using Node.js version 14 or higher
Node.js version
v16.14.2
Reproduction repository
https://github.com/mathanpec/msw-memory-leak-test
Reproduction steps
- Use node version
16
. - Clone the reproduction repo (originally created by @mathanpec for #710).
- Edit package.json to change
msw
package version to0.39.2
and executeyarn install
. - Execute
node --expose-gc ./node_modules/.bin/jest --silent --runInBand --logHeapUsage
. - Notice the heap usage increase for each test.
Current behavior
There seems to be some memory leak going on when using node 16
.
The heap profile also seems to show multiple copies of the same msw index file.
Expected behavior
Memory heap should not increase for each test file run when using node 16
. Executing jest with node 14
does not cause any memory leak as shown in the following screenshot:
Issue Analytics
- State:
- Created a year ago
- Reactions:14
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to Find, Fix, and Prevent Node.js Memory Leaks
Memory management for any application is essential. This post looks at what memory leaks are and how to avoid them in Node.js applications....
Read more >Node.js Memory Leak Detection: How to Debug & Avoid ...
A quick way to fix Node.js memory leaks in the short term is to restart the app. Make sure to do this first...
Read more >javascript - Strange Nodejs memory leak
Having a large graph of objects referenced from the root can lead to a memory leak. Multiple references: When the same object is...
Read more >Troubleshooting Node.js Memory Use
If a memory leak is small and only happens on a rarely used code path, then it's often not worth the effort of...
Read more >Issue 12198 in v8: vm Script memory leak in Node.js 14 / 16
Hey, the leak is caused by not disposing the realms, add Realm.dispose(realm) to the script above and d8 won't crash. The Realm needs...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ah i see, so the memory leak is because of the node, not the msw
We also experience this issue, except we don’t use
msw
. It also reproduces on Node 18.