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

Detect what code is causing a collection to leak #14

Closed
nolanlawson opened this issue Dec 18, 2021 · 1 comment · Fixed by #25
Closed

Detect what code is causing a collection to leak #14

nolanlawson opened this issue Dec 18, 2021 · 1 comment · Fixed by #25
Labels
enhancement New feature or request

Comments

@nolanlawson
Copy link
Owner

For Arrays, Maps, and Sets, it should be possible to override functions that append to it and then capture stacktraces for when these functions are called. For plain Objects I'm not sure.

Right now I document this in the readme as a manual step, but it'd be nice to automate it...

@nolanlawson
Copy link
Owner Author

Hah, it actually is possible to capture setters on a regular object:

const obj = {}
const proxy = new Proxy(Object.create(null), { set (obj, prop, val) { debugger; return (obj[prop] = val) } })
Object.setPrototypeOf(obj, proxy)
obj.foo = 'bar'

@nolanlawson nolanlawson added the enhancement New feature or request label Dec 28, 2021
nolanlawson added a commit that referenced this issue Dec 28, 2021
* feat: track stacktraces for leaking collections

Fixes #14

* docs: update

* fix: unnecessary async code, refactor

* fix: code comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant