Skip to main content

memlab analyze

Run heap analysis on heap snapshots.

memlab analyze <PLUGIN_NAME> [PLUGIN_OPTIONS]

Example output​

$ memlab analyze

  Heap analysis plugin name missing

  memlab analyze <PLUGIN_NAME> [PLUGIN_OPTIONS]
  Run heap analysis on heap snapshots.
  Options: --analysis-plugin --heap-parser-dict-fast-store-size
           --work-dir

   memlab analyze unbound-collection
   Check unbound collection growth (e.g., Map with growing number of entries)
   Options: --snapshot-dir

   memlab analyze collections-with-stale
   Analyze collections holding stale objects
   Options: --snapshot --output

   memlab analyze detached-DOM
   Get detached DOM elements
   Options: --snapshot --output

   memlab analyze global-variable
   Get global variables in heap
   Options: --snapshot --output

   memlab analyze object
   Get properties inside an object
   Options: --snapshot --node-id --output

   memlab analyze object-fanout
   Get objects with the most out-going references in heap
   Options: --snapshot --output

   memlab analyze object-shallow
   Get objects by key and value, without recursing into sub-objects
   Options: --snapshot

   memlab analyze shape
   List the shapes that retained most memory
   Options: --snapshot

   memlab analyze object-size
   Get the largest objects in heap
   Options: --snapshot --output

   memlab analyze unbound-object
   Check unbound object growth (a single object with growing retained size)
   Options: --snapshot-dir

   memlab analyze react-hooks
   Show a memory breakdown of the most memory-consuming React components and their React hooks. This works best with
   unminified heap snapshots taken from React apps running in Dev mode. But also supports minified heap snapshots taken
   from React apps in production mode.
   Options: --snapshot

   memlab analyze unbound-shape
   Get shapes with unbound growth (a class of objects with growing aggregated retained size)
   Options: --snapshot-dir

   memlab analyze string
   Find duplicated string instances in heap
   Options: --snapshot

   memlab analyze unmounted-fiber-node
   Get unmounted React Fiber nodes
   Options: --snapshot --output

How to read the output​

Without a plugin name, memlab analyze lists the available analysis plugins and their options. Each plugin has its own page, listed below, with an example of its output.

Subcommands​

CommandDescription
memlab analyze unbound-collectionCheck unbound collection growth (e.g., Map with growing number of entries)
memlab analyze collections-with-staleAnalyze collections holding stale objects
memlab analyze detached-DOMGet detached DOM elements
memlab analyze global-variableGet global variables in heap
memlab analyze objectGet properties inside an object
memlab analyze object-fanoutGet objects with the most out-going references in heap
memlab analyze object-shallowGet objects by key and value, without recursing into sub-objects
memlab analyze shapeList the shapes that retained most memory
memlab analyze object-sizeGet the largest objects in heap
memlab analyze unbound-objectCheck unbound object growth (a single object with growing retained size)
memlab analyze react-hooksShow a memory breakdown of the most memory-consuming React components and their React hooks. This works best with unminified heap snapshots taken from React apps running in Dev mode. But also supports minified heap snapshots taken from React apps in production mode.
memlab analyze unbound-shapeGet shapes with unbound growth (a class of objects with growing aggregated retained size)
memlab analyze stringFind duplicated string instances in heap
memlab analyze unmounted-fiber-nodeGet unmounted React Fiber nodes

Options​

  • --analysis-plugin: specify the external heap analysis plugin file (must be a vanilla JS file ended with Analysis.js suffix)
  • --heap-parser-dict-fast-store-size: the size threshold for switching from fast store to slower store in the heap snapshot parser. The default value is 5,000,000. If you get the FATAL ERROR: invalid table size Allocation failed - JavaScript heap out of memory error, try to decrease the threshold here
  • --work-dir: set the working directory of the current run

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