Skip to content

src: improve memory management in ffi source#63071

Open
addaleax wants to merge 2 commits intonodejs:mainfrom
addaleax:ffi-mem-management
Open

src: improve memory management in ffi source#63071
addaleax wants to merge 2 commits intonodejs:mainfrom
addaleax:ffi-mem-management

Conversation

@addaleax
Copy link
Copy Markdown
Member

@addaleax addaleax commented May 1, 2026

src: use unique_ptr for ffi memory management
ffi: make FFIFunctionInfo a BaseObject subclass

This brings the typical benefits of using BaseObject,
such as a reduced risk of memory management pitfalls
(e.g. accidental v8::Global recursive references)
and diagnostic tracking.

addaleax and others added 2 commits May 1, 2026 23:41
Signed-off-by: Anna Henningsen <anna@addaleax.net>
This brings the typical benefits of using `BaseObject`,
such as a reduced risk of memory management pitfalls
(e.g. accidental `v8::Global` recursive references)
and diagnostic tracking.

Signed-off-by: Anna Henningsen <anna@addaleax.net>
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/ffi

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels May 1, 2026
@addaleax addaleax added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels May 1, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 1, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

❌ Patch coverage is 79.59184% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.65%. Comparing base (69a970f) to head (ce75f84).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/node_ffi.cc 82.97% 4 Missing and 4 partials ⚠️
src/node_ffi.h 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63071      +/-   ##
==========================================
- Coverage   91.48%   89.65%   -1.84%     
==========================================
  Files         360      712     +352     
  Lines      151674   220514   +68840     
  Branches    23917    42277   +18360     
==========================================
+ Hits       138763   197703   +58940     
- Misses      12635    14662    +2027     
- Partials      276     8149    +7873     
Files with missing lines Coverage Δ
src/node_ffi.h 61.53% <0.00%> (ø)
src/node_ffi.cc 70.01% <82.97%> (ø)

... and 475 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@ShogunPanda ShogunPanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants