Skip to main content

memlab snapshot-header

Print node and edge counts and the memory needed to analyze a heap snapshot, read from its header without parsing the snapshot

memlab snapshot-header --snapshot <HEAP_SNAPSHOT_FILE>

Examples​

memlab snapshot-header --snapshot-dir <DIR_CONTAINING_SNAPSHOTS>
memlab snapshot-header --snapshot <HEAP_SNAPSHOT_FILE> --output json

Example output​

$ memlab snapshot-header --snapshot /tmp/memlab-example/leak/data/cur/s3.heapsnapshot
Snapshot  /tmp/memlab-example/leak/data/cur/s3.heapsnapshot
  file size             3.3 MB
  nodes                 36,425
  edges                 168,842 (4.6 per node)
  allocation stacks     not recorded
  detachedness          recorded
Memory needed to analyze it
  about 7 MB of JS heap; this Node.js process has 4,144 MB

How to read the output​

memlab snapshot-header reads only the header of a snapshot file, so it is instant even for files of several GB. Use it to check a snapshot before analyzing it.

  • nodes and edges are the number of objects and references in the snapshot.
  • allocation stacks tells whether the snapshot recorded where each object was allocated.
  • detachedness tells whether the browser marked detached DOM elements. memlab's leak detection uses this.
  • Memory needed to analyze it estimates the JS heap memlab needs to load the snapshot, compared with what the current Node.js process can use. If the estimate is larger, pass a larger --max-old-space-size to Node.js.

Options​

  • --snapshot: set file path of the heap snapshot under analysis
  • --snapshot-dir: set directory path containing all heap snapshots under analysis
  • --output: output format of the report: 'text' (default) or 'json'

The universal options (--help, --verbose, ...) work with this command too.