Title: ffi: fast buffer path leaks V8 handles on every optimized call · Issue #66866 · nodejs/node · GitHub
Open Graph Title: ffi: fast buffer path leaks V8 handles on every optimized call · Issue #66866 · nodejs/node
X Title: ffi: fast buffer path leaks V8 handles on every optimized call · Issue #66866 · nodejs/node
Description: Version main Platform macOS Subsystem ffi What steps will reproduce the bug? import { dlopen } from 'node:ffi'; const { functions: { strlen } } = dlopen(null, { strlen: { arguments: ['buffer'], return: 'u64' }, }); const kind = process.a...
Open Graph Description: Version main Platform macOS Subsystem ffi What steps will reproduce the bug? import { dlopen } from 'node:ffi'; const { functions: { strlen } } = dlopen(null, { strlen: { arguments: ['buffer'], ret...
X Description: Version main Platform macOS Subsystem ffi What steps will reproduce the bug? import { dlopen } from 'node:ffi'; const { functions: { strlen } } = dlopen(null, { strlen: { arguments: ['b...
Opengraph URL: https://github.com/nodejs/node/issues/66866
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ffi: fast buffer path leaks V8 handles on every optimized call","articleBody":"### Version\n\nmain\n\n### Platform\n\n```text\nmacOS\n```\n\n### Subsystem\n\nffi\n\n### What steps will reproduce the bug?\n\n```js\nimport { dlopen } from 'node:ffi';\n\nconst { functions: { strlen } } = dlopen(null, {\n strlen: { arguments: ['buffer'], return: 'u64' },\n});\n\nconst kind = process.argv[2] ?? 'view';\nconst ab = new ArrayBuffer(16); // zero-filled, so strlen() returns 0n\nconst arg = kind === 'arraybuffer' ? ab : new Uint8Array(ab);\n\nfunction hot(x) { return strlen(x); }\n\nconst mb = () => Math.round(process.memoryUsage().rss / 2 ** 20);\nconst before = mb();\nfor (let i = 0; i \u003c 2e7; i++) hot(arg);\nconsole.log(`${kind}: rss ${before} MB -> ${mb()} MB after 2e7 calls`);\n```\n\nRun with\n```console\n$ node --no-warnings repro.mjs view\n\n$ node --no-warnings repro.mjs arraybuffer\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways\n\n### What is the expected behavior? Why is that the expected behavior?\n\nRSS stays flat, as it does for an `ArrayBuffer` argument. A call that only reads a backing-store pointer should not keep allocating memory.\n\n### What do you see instead?\n\n```console\nview: rss 50 MB -> 675 MB after 2e7 calls\narraybuffer: rss 50 MB -> 60 MB after 2e7 calls\n```\n\nThat is about 32 bytes per call for `ArrayBufferView` arguments.\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/trivikr","@type":"Person","name":"trivikr"},"datePublished":"2026-10-20T01:17:47Z","url":"https://github.com/nodejs/node/issues/66866"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:723aaa42-9422-470b-54dd-532551d49c2b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 82BC:2CA452:99F77:C3CDD:6B033636 |
| html-safe-nonce | b5fbb2dcfb23d2ed3df2cc900ee972d9c1965f633aa172f155f2798dd939c6fd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MkJDOjJDQTQ1Mjo5OUY3NzpDM0NERDo2QjAzMzYzNiIsInZpc2l0b3JfaWQiOiI0MTg4MDY4MjMzMjY3NTkwNzEwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e99d7237353e2f3a5a96a17e573d5190c934ab95c75e2b05f2a3e6f8fcaf8d5b |
| hovercard-subject-tag | issue:5934214334 |
| 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/66866/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8712114bc99b397728564a5e2621617e7099b796ec24a6d897ca9516ff2f0b2d/nodejs/node/issues/66866 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8712114bc99b397728564a5e2621617e7099b796ec24a6d897ca9516ff2f0b2d/nodejs/node/issues/66866 |
| og:image:alt | Version main Platform macOS Subsystem ffi What steps will reproduce the bug? import { dlopen } from 'node:ffi'; const { functions: { strlen } } = dlopen(null, { strlen: { arguments: ['buffer'], ret... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | trivikr |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width