memlab analyze collections-with-stale
Analyze collections holding stale objects
memlab analyze collections-with-stale
Example output
$ memlab analyze collections-with-stale --snapshot /tmp/memlab-example/leak/data/cur/s3.heapsnapshot
Collections holding stale objects:
· (@50805) 60 bytes (1 out of 2 elements are stale):
@65915How to read the output
memlab analyze collections-with-stale finds collections (arrays, Maps, Sets, and objects) that hold stale objects. Stale objects are detached DOM elements and unmounted React Fiber nodes, which the app no longer uses.
Each entry is the collection's id and retained size, how many of its elements are stale, and the ids of the stale elements. For a Map or Set, the collection is its internal table.
In this example, the collection is the internal table of the global openedDialogs Set, and the stale element is the <div class="settings"> of the closed dialog. The app adds each dialog to the Set but never deletes it when the dialog closes.
Options
--snapshot: set file path of the heap snapshot under analysis--output: specify output format of the analysis (available options: 'text', 'json'; defaults to 'text')
The universal options (--help, --verbose, ...) work with this command too.