Detecting memory leaks through shared function context
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- javascript, nodejs
- Domain
- observability
Research direction
Start with the linked diagnostics-summit document and the heap-snapshot reconstruction approach described here; no repository files or tests are named. Establish how heap snapshots can identify objects retained by a shared function context, and define a reproducible result that demonstrates the detected pattern.
Written by the indexing model from the issue text.
Description
This was discussed at the diagnostics summit, and I want to take the discussion here. The document I referred to is this, by my colleague @jakobkummerow.
The gist of the problem is:
const f = (function() {
let a = {};
let b = {};
let c = ()=>a; // forces a to be context-allocated.
let d = ()=>b; // forces b to be context-allocated.
return d; // the function context escapes and is kept alive.
})();
The object assigned to a is no longer accessible though JavaScript, but is kept alive because it is allocated onto the same context as b, which remains accessible through d.
Detecting this pattern at runtime would require the VM to keep track of additional meta-data, which does not pay off. However, we could, based on the information from a heap snapshot reconstruct missing metadata and detect this pattern.
- Dominant language
- No language data
- Stars
- 550
- Forks
- 69
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nodejs/diagnostics
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
nodejs/diagnostics#648 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 20/100
nodejs/diagnostics#690 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 20/100
nodejs/diagnostics#689 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 25/100
nodejs/diagnostics#688 ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
nodejs/diagnostics#687 ·
All issues in nodejs/diagnostics
Similar issues
-
comp/tools P2 type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
NousResearch/hermes-agent#117428 ·
-
sdk
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
langchain-ai/langsmith-sdk#3566 ·
-
clawsweeper:bulk-filed clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:other issue-rating: 🦞 diamond lobster P2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
[Bug] "Detected rollback scenario" logged on every reconcile for a steady-state current version Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
CherryHQ/cherry-studio#20799 · 1 reaction ·