René's URL Explorer Experiment


Title: vm contexts never get freed after Jest runs a big test file (Node 24+, retained maps) · Issue #66490 · nodejs/node · GitHub

Open Graph Title: vm contexts never get freed after Jest runs a big test file (Node 24+, retained maps) · Issue #66490 · nodejs/node

X Title: vm contexts never get freed after Jest runs a big test file (Node 24+, retained maps) · Issue #66490 · nodejs/node

Description: Version v24.21.0 (also v24.8.0, v24.15.0, v26.10.0; not v22.14.0 or v22.18.0) Platform Darwin 25.6.0 Darwin Kernel Version 25.6.0: Fri Jul 31 19:17:26 PDT 2026; root:xnu-12377.161.14~5/RELEASE_ARM64_T6041 arm64 Subsystem vm What s...

Open Graph Description: Version v24.21.0 (also v24.8.0, v24.15.0, v26.10.0; not v22.14.0 or v22.18.0) Platform Darwin 25.6.0 Darwin Kernel Version 25.6.0: Fri Jul 31 19:17:26 PDT 2026; root:xnu-12377.161.14~5/RELEA...

X Description: Version v24.21.0 (also v24.8.0, v24.15.0, v26.10.0; not v22.14.0 or v22.18.0) Platform Darwin <host> 25.6.0 Darwin Kernel Version 25.6.0: Fri Jul 31 19:17:26 PDT 2026; root:xnu-12377.161.14~5...

Opengraph URL: https://github.com/nodejs/node/issues/66490

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"vm contexts never get freed after Jest runs a big test file (Node 24+, retained maps)","articleBody":"### Version\n\nv24.21.0 (also v24.8.0, v24.15.0, v26.10.0; not v22.14.0 or v22.18.0)\n\n### Platform\n\n```text\nDarwin \u003chost> 25.6.0 Darwin Kernel Version 25.6.0: Fri Jul 31 19:17:26 PDT 2026; root:xnu-12377.161.14~5/RELEASE_ARM64_T6041 arm64\n```\n\n### Subsystem\n\nvm\n\n### What steps will reproduce the bug?\n\nI put a small repro here: https://github.com/markmssd/nodejs-repro/tree/vm-context-retained-maps\n\n```sh\ngit clone -b vm-context-retained-maps https://github.com/markmssd/nodejs-repro.git\ncd nodejs-repro\nnpm install\nnpm run repro        # \"still in memory\" goes up to 8\nnpm run repro:fixed  # same thing with --retain-maps-for-n-gc=0, stays at 1\n```\n\nJest runs each test file in its own `vm` context. `many.test.js` has 3000 trivial tests, which is enough to get Jest's per-test code optimized, and then there are seven files with a single test each. `counting-environment.js` is Jest's node environment plus a small counter: after each test file it runs a GC and prints how many test-file globals are still around.\n\n### How often does it reproduce? Is there a required condition?\n\nEvery time on Node 24 and 26. You just need one test file that does enough per-test work for Jest's code to get optimized. 3000 empty tests does it. In our real project, about 120 tests is enough, because our setup files register around 12 beforeEach hooks.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nOnce a test file is done, its context should be garbage collected, so only the file that's currently running should still be in memory:\n\n```\ntest files finished: 1, still in memory: 1\ntest files finished: 2, still in memory: 1\n...\ntest files finished: 8, still in memory: 1\n```\n\nThat's what I get on Node 22, and on Node 24/26 with `--retain-maps-for-n-gc=0` (`npm run repro:fixed`).\n\n### What do you see instead?\n\nOn Node 24 and 26, none of the test files after `many.test.js` ever get freed:\n\n```\ntest files finished: 1, still in memory: 1\ntest files finished: 2, still in memory: 2\n...\ntest files finished: 8, still in memory: 8\n```\n\nThis is how I found it: in our real test suite, one Jest worker running 180 test files ended up holding 44 old contexts and about 1.1 GB of heap. With `--retain-maps-for-n-gc=0` it's 2 contexts and around 330 MB. In CI our workers peak at 1.4–1.9 GB of retained heap, and 670–820 MB with the flag.\n\n### Additional information\n\n- The old contexts aren't strongly reachable. A heap snapshot (`v8.writeHeapSnapshot()`, whose GC tries to reduce memory) frees them, and afterwards the snapshot only shows the current one. Plain `global.gc()` calls never do, which is why I think it's the retained maps. `--retain-maps-for-n-gc=0` makes it go away completely.\n- `--no-maglev` mostly hides it (2 stay alive instead of all of them), I assume because less code gets optimized.\n- I did find one strong path, but it only keeps a single previous test file alive: from Jest's runtime, through the `FeedbackVector` / `AllocationSite` of `createInitialModule`, the boilerplate object's `Map` → `DescriptorArray` → `AccessorPair` (a `module.parent` getter Jest defines on every module with `Object.defineProperty`), and from that getter's closure to the test file's environment.\n- I couldn't reproduce it with a plain `node:vm` loop (new context each iteration with a hot function inside), so it probably depends on how Jest's code is shared between the outer realm and the contexts.","author":{"url":"https://github.com/markmssd","@type":"Person","name":"markmssd"},"datePublished":"2026-10-03T23:32:26Z","url":"https://github.com/nodejs/node/issues/66490"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:1202875e-da74-8f0c-6a4f-eef566b5d7fb
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idEBCA:142296:6E8224:8FC7A3:6AED305B
html-safe-nonce87a24d3bf892d7852e0f88e5b94881e51b70a973b15def24a07d7f8ff94ef6fe
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQkNBOjE0MjI5Njo2RTgyMjQ6OEZDN0EzOjZBRUQzMDVCIiwidmlzaXRvcl9pZCI6IjI2MTk5NjM0MTU2NTk4ODQ2MzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac0a4db0c5c3875ac9ae1da9303fe530a07285543dec5cdc684fe7e73dbecb7c08
hovercard-subject-tagissue:5694586843
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/66490/issue_layout
twitter:imagehttps://opengraph.githubassets.com/485266cc5a8064e889f2aae03cf019df2aaa34a8a087a2f8fc45ec5dd37d6086/nodejs/node/issues/66490
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/485266cc5a8064e889f2aae03cf019df2aaa34a8a087a2f8fc45ec5dd37d6086/nodejs/node/issues/66490
og:image:altVersion v24.21.0 (also v24.8.0, v24.15.0, v26.10.0; not v22.14.0 or v22.18.0) Platform Darwin 25.6.0 Darwin Kernel Version 25.6.0: Fri Jul 31 19:17:26 PDT 2026; root:xnu-12377.161.14~5/RELEA...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemarkmssd
hostnamegithub.com
expected-hostnamegithub.com
Nonee51d0b7b5ab34b1688c05b54c3ed17b8658b2fa9bca973a9c740683ccb12cf4a
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release59ebb7b901cc154ecc179a44f266fcf69f343b30
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/66490#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F66490
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F66490
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/66490
Reloadhttps://github.com/nodejs/node/issues/66490
Reloadhttps://github.com/nodejs/node/issues/66490
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues656 (656)https://github.com/nodejs/node/issues
Pull requests666 (666)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/pulse
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66490
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66490
vm contexts never get freed after Jest runs a big test file (Node 24+, retained maps)https://github.com/nodejs/node/issues/66490#top
v8 engineIssues and PRs related to the V8 dependency.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22v8%20engine%22
vmIssues and PRs related to the vm subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22vm%22
https://github.com/markmssd
markmssdhttps://github.com/markmssd
on Oct 3, 2026https://github.com/nodejs/node/issues/66490#issue-5694586843
https://github.com/markmssd/nodejs-repro/tree/vm-context-retained-mapshttps://github.com/markmssd/nodejs-repro/tree/vm-context-retained-maps
https://github.com/inoway46
inoway46https://github.com/inoway46
on Oct 8, 2026https://github.com/nodejs/node/issues/66490#issuecomment-6058550363
@markmssdhttps://github.com/markmssd
inoway46https://github.com/inoway46
vmIssues and PRs related to the vm subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22vm%22
v8 engineIssues and PRs related to the V8 dependency.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22v8%20engine%22
on Oct 8, 2026https://github.com/nodejs/node/issues/66490#event-32780380644
https://github.com/markmssd
markmssdhttps://github.com/markmssd
on Oct 8, 2026https://github.com/nodejs/node/issues/66490#issuecomment-6059789098
https://github.com/markmssd
markmssdhttps://github.com/markmssd
on Oct 8, 2026https://github.com/nodejs/node/issues/66490#issuecomment-6060030661
https://issues.chromium.org/issues/571157135https://issues.chromium.org/issues/571157135
https://github.com/inoway46
inoway46https://github.com/inoway46
on Oct 14, 2026https://github.com/nodejs/node/issues/66490#issuecomment-6169435432
https://chromium-review.googlesource.com/c/v8/v8/+/8557820https://chromium-review.googlesource.com/c/v8/v8/+/8557820
https://github.com/inoway46/node/actions/runs/38505282655https://github.com/inoway46/node/actions/runs/38505282655
https://github.com/inoway46/node/actions/runs/38432566001https://github.com/inoway46/node/actions/runs/38432566001
ea6ec93https://github.com/nodejs/node/commit/ea6ec93b2f6504a757660891402872897a2db81a
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/66490
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66490
v8 engineIssues and PRs related to the V8 dependency.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22v8%20engine%22
vmIssues and PRs related to the vm subsystem.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22vm%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.