src: free placeholder nodes for cppgc wrappers in MemoryTracker - #65793
Open
codebytere wants to merge 1 commit into
Open
src: free placeholder nodes for cppgc wrappers in MemoryTracker#65793codebytere wants to merge 1 commit into
codebytere wants to merge 1 commit into
Conversation
Collaborator
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65793 +/- ##
==========================================
+ Coverage 90.17% 90.19% +0.01%
==========================================
Files 771 771
Lines 265470 265472 +2
Branches 50463 50468 +5
==========================================
+ Hits 239383 239430 +47
+ Misses 17055 16998 -57
- Partials 9032 9044 +12
🚀 New features to boost your workflow:
|
jasnell
approved these changes
Sep 4, 2026
codebytere
force-pushed
the
fix/embedder-heap-snapshot-cppgc-node-leak
branch
from
September 7, 2026 22:04
191eee3 to
7e3cbc7
Compare
Collaborator
codebytere
requested review from
anonrig
and removed request for
addaleax and
legendecas
September 10, 2026 12:51
`MemoryTracker::AddNode(const CppgcMixin*)` allocates a `MemoryRetainerNode` that only stands in for the wrapper's JS node while its `MemoryInfo()` runs; unlike the other node kinds it is not handed to the `EmbedderGraph`, and nothing freed it. Every heap snapshot (or other `BuildEmbedderGraph` call) leaked one node per live `vm.Script` or `vm` context. Keep the placeholders in the tracker and free them with it, and make the already-seen path in `Track(const CppgcMixin*)` add its edge to the wrapper's JS node like the first visit does, so the graph never refers to a placeholder. Refs: nodejs#56534 Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
codebytere
force-pushed
the
fix/embedder-heap-snapshot-cppgc-node-leak
branch
from
September 10, 2026 23:59
7e3cbc7 to
1efde11
Compare
Collaborator
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every heap snapshot (
v8.getHeapSnapshot(),--heapsnapshot-near-heap-limit, the inspector) leaks oneMemoryRetainerNodeper livevm.Scriptorvmcontext:MemoryTracker::AddNode(const CppgcMixin*)allocates a placeholder that only stands in for the wrapper's JS node whileMemoryInfo()runs and, unlike the other node kinds, never hands it to the graph or frees it.The tracker now owns those placeholders and frees them when it is destroyed, and the already-seen branch of
Track(const CppgcMixin*)links to the wrapper's JS node like the first visit so the graph never points at a placeholder.Tests:
EnvironmentTest.HeapSnapshotWithCppgcWrappersDoesNotLeak(LSAN before); the heapsnapshot/heapdump suites pass.Refs: #56534
Disclosure: the code, test and this description were written by Claude Code, directed and reviewed by @codebytere.