Closed JacksonGL closed 2 years ago
I wonder if a slightly nicer/stricter API would be
import {tagObject, getCurrentNodeHeap} from '@memlab/core';
let o = new InstantObject();
tagObject(o, 'maybe-leak-from-f1');
Also, not sure if it would make the internals more complicated, but instead of __memlab_tag - would it be possible to use a Symbol instead of a string key to guarentee that props added by memlab wont change application logic (i.e. it wouldn't show up in prop enumerations or in serialized JSON output etc.)
I wonder if a slightly nicer/stricter API would be
import {tagObject, getCurrentNodeHeap} from '@memlab/core'; let o = new InstantObject(); tagObject(o, 'maybe-leak-from-f1');
Also, not sure if it would make the internals more complicated, but instead of __memlab_tag - would it be possible to use a Symbol instead of a string key to guarentee that props added by memlab wont change application logic (i.e. it wouldn't show up in prop enumerations or in serialized JSON output etc.)
Update the commit by adding a new tabObject
API that doesn't modify the tagged object. The idea is using a WeakSet
to store references to tagged objects, and heap.hasObjectWithTag
will traverse the WeakSet
and check that the object with associated tag has no strong references in heap.
@JacksonGL has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
Enables memlab to capture and return the current node.js heap, this could be useful in the following ways:
For example: