question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory leak while using node 16 (but not 14)

See original GitHub issue

Prerequisites

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

  1. Use node version 16.
  2. Clone the reproduction repo (originally created by @mathanpec for #710).
  3. Edit package.json to change msw package version to 0.39.2 and execute yarn install.
  4. Execute node --expose-gc ./node_modules/.bin/jest --silent --runInBand --logHeapUsage.
  5. Notice the heap usage increase for each test.

Current behavior

There seems to be some memory leak going on when using node 16.

Screenshot 2022-04-05 at 8 15 11 PM

The heap profile also seems to show multiple copies of the same msw index file. Screenshot 2022-04-05 at 9 07 52 PM

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:

Screenshot 2022-04-05 at 8 14 27 PM

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:14
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
finalightcommented, May 27, 2022

We also experience this issue, except we don’t use msw. It also reproduces on Node 18.

ah i see, so the memory leak is because of the node, not the msw

2reactions
artkoshelevcommented, May 27, 2022

We also experience this issue, except we don’t use msw. It also reproduces on Node 18.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found