Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detecting memory leaks through shared function context #281

Open
hashseed opened this issue Mar 18, 2019 · 5 comments
Open

Detecting memory leaks through shared function context #281

hashseed opened this issue Mar 18, 2019 · 5 comments
Labels
blind-spot Issues which can't be detected by current diagnostics tools. never stale

Comments

@hashseed
Copy link
Member

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.

@hashseed
Copy link
Member Author

@BridgeAR @mcollina

@mcollina
Copy link
Member

mcollina commented Mar 18, 2019

The document is not publicly accessible.

Having some automated tool that can detect this pattern would be fantastic. Note that this happens quite frequently in Node.js code and the vast majority of it is not a memory leak. Tracking and resolving those would be equally valuable, mainly because they will increase the memory footprint and simplify the GC job.

@github-actions
Copy link

This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.

@github-actions github-actions bot added the stale label Jul 17, 2020
@mmarchini mmarchini added never stale blind-spot Issues which can't be detected by current diagnostics tools. and removed stale labels Jul 20, 2020
@github-actions
Copy link

This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.

@github-actions github-actions bot added the stale label Jul 23, 2022
@RafaelGSS RafaelGSS removed the stale label Jul 23, 2022
@github-actions
Copy link

This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.

@github-actions github-actions bot added the stale label Oct 22, 2022
@github-actions github-actions bot removed the stale label Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blind-spot Issues which can't be detected by current diagnostics tools. never stale
Projects
None yet
Development

No branches or pull requests

4 participants