Title: v24: discarded vm contexts cause OOM; possible V8 backport · Issue #66053 · nodejs/node · GitHub
Open Graph Title: v24: discarded vm contexts cause OOM; possible V8 backport · Issue #66053 · nodejs/node
X Title: v24: discarded vm contexts cause OOM; possible V8 backport · Issue #66053 · nodejs/node
Description: Version v24.21.0 Platform Linux x86_64, kernel 6.8.0-139-generic Subsystem vm, V8 What steps will reproduce the bug? Save as repro.mjs; run node --max-old-space-size=128 repro.mjs. import { runInNewContext } from "node:vm"; import { setI...
Open Graph Description: Version v24.21.0 Platform Linux x86_64, kernel 6.8.0-139-generic Subsystem vm, V8 What steps will reproduce the bug? Save as repro.mjs; run node --max-old-space-size=128 repro.mjs. import { runInNe...
X Description: Version v24.21.0 Platform Linux x86_64, kernel 6.8.0-139-generic Subsystem vm, V8 What steps will reproduce the bug? Save as repro.mjs; run node --max-old-space-size=128 repro.mjs. import { runInNe...
Opengraph URL: https://github.com/nodejs/node/issues/66053
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"v24: discarded vm contexts cause OOM; possible V8 backport","articleBody":"### Version\n\nv24.21.0\n\n### Platform\n\n```text\nLinux x86_64, kernel 6.8.0-139-generic\n```\n\n### Subsystem\n\nvm, V8\n\n### What steps will reproduce the bug?\n\nSave as `repro.mjs`; run `node --max-old-space-size=128 repro.mjs`.\n\n```js\nimport { runInNewContext } from \"node:vm\";\nimport { setImmediate } from \"node:timers/promises\";\n\nconst source = `\n globalThis.payload = new Array(1_000_000).fill(0);\n ${Array.from({ length: 30 }, (_, index) => `\n function work${index}(values) {\n let result = 0;\n for (let i = 0; i \u003c values.length; ++i) {\n result += Math.sqrt(values[i] * values[i] + ${index});\n }\n return result;\n }\n `).join(\"\\n\")}\n const values = [1, 2, 3, 4, 5];\n for (let i = 0; i \u003c 1000; ++i) {\n ${Array.from({ length: 30 }, (_, index) => `work${index}(values);`).join(\"\\n\")}\n }\n`;\n\nfor (let i = 0; i \u003c 100; ++i) {\n runInNewContext(source + `\\n// ${i}`);\n await setImmediate();\n}\nconsole.log(\"Completed\");\n```\n\n### How often does it reproduce? Is there a required condition?\n\nRepeatedly on v24.15.0, v24.16.0, and v24.21.0. Completes on v22.23.2, v26.8.2, or with `--no-concurrent-recompilation` on v24.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nPrint `Completed`; discarded contexts should be collectible.\n\n### What do you see instead?\n\n```\nFATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory\n```\n\n### Additional information\n\nThis surfaced in jsdom’s WPT runner with the default ~4 GB heap; the smaller limit makes this reproduction quick. Sampled heap retainers point through V8’s `IdentityMapBase` to realm prototypes, keeping entire windows alive.\n\nCould V8’s [“Stop collecting array and object prototypes”](https://github.com/v8/v8/commit/8901c793e4392dfea261bcbf9c679e2978847d4d) change be backported to v24? Its later [thread-safety follow-up](https://github.com/v8/v8/commit/c3553509f460b104cb8d4faf610d229a2d033f7b) might also be relevant.\n\nI haven't verified that those commits are the key ones, but it's worth trying.","author":{"url":"https://github.com/domenic","@type":"Person","name":"domenic"},"datePublished":"2026-09-16T03:36:30Z","url":"https://github.com/nodejs/node/issues/66053"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:39005b1c-64fd-f2f4-bdba-df141dadf9c6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 83EE:D9695:76B397:9A8F99:6AED32AB |
| html-safe-nonce | 983a4f8f87a4fa842b066f3be56ab9d02c8cfc78c3f7580354c38f0d1a0bece4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4M0VFOkQ5Njk1Ojc2QjM5Nzo5QThGOTk6NkFFRDMyQUIiLCJ2aXNpdG9yX2lkIjoiMjk4NTYyODgzNTIyNzk3MjI2NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7279683e6949211008b6c1604eb6bf8cbf27afea53a6cd9c574be016b99dc01c |
| hovercard-subject-tag | issue:5469917441 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/66053/issue_layout |
| twitter:image | https://opengraph.githubassets.com/34a120285f4aa31441714b3a8a3eb16ee3e2bac9faf2e8429b1071e95d834d51/nodejs/node/issues/66053 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/34a120285f4aa31441714b3a8a3eb16ee3e2bac9faf2e8429b1071e95d834d51/nodejs/node/issues/66053 |
| og:image:alt | Version v24.21.0 Platform Linux x86_64, kernel 6.8.0-139-generic Subsystem vm, V8 What steps will reproduce the bug? Save as repro.mjs; run node --max-old-space-size=128 repro.mjs. import { runInNe... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | domenic |
| hostname | github.com |
| expected-hostname | github.com |
| None | e51d0b7b5ab34b1688c05b54c3ed17b8658b2fa9bca973a9c740683ccb12cf4a |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 59ebb7b901cc154ecc179a44f266fcf69f343b30 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width