Skip to main content

memlab analyze object

Get properties inside an object

memlab analyze object 

Example output​

$ memlab analyze object --snapshot /tmp/memlab-example/leak/data/cur/s3.heapsnapshot --node-id @71391
Heap node (object) @71391
 name: SettingsDialog
 # of references: 6
 # of referrers: 3
 shallow size: 60
 retained size: 806616
 dominator node: @71399

REFERENCES:
·  --container--> @65915 native Detached <div class="settings">: 7 edges, 45.3KB, refs: [container]
·  --labels--> @71393 Array: 243 edges, 6.2KB, refs: [labels]
·  --history--> @71395 Array: 3 edges, 800KB, refs: [history]
·  --unsubscribe--> @71397 closure : 6 edges, 52 bytes, refs: [unsubscribe]
·  --__proto__--> @50821 Object { close, constructor, open }: 6 edges, 799 bytes, refs: [__proto__, prototype]
·  --map--> @71039 object shape system / Map: 15 edges, 224 bytes, refs: [map, transition]

REFERRERS:
·  @71399 system / Context / scope @65777: 5 edges, 806.6KB, refs: [listener] --dialog-->
·  @71399 system / Context / scope @65777: 5 edges, 806.6KB, refs: [listener] --this-->
·  @65917 WeakRef: 3 edges, 16 bytes, refs: [] --target-->

How to read the output​

memlab analyze object prints one object, its references, and its referrers.

  • shallow size and retained size are in bytes. The retained size is the memory freed if nothing referenced the object. dominator node is the closest object that every path from a GC root to this object goes through.
  • REFERENCES are the objects this one points to, with the property name on the arrow.
  • REFERRERS are the objects that point to this one, with the property name on the arrow after them.

In this example, the SettingsDialog retains 806.6KB, almost all of it in its 800KB history array. Its referrers show what keeps it alive: a closure scope that holds it as dialog and this (the scope of the event bus listener) and a WeakRef, which does not keep it alive.

Options​

  • --snapshot: set file path of the heap snapshot under analysis
  • --node-id: set heap node ID
  • --output: specify output format of the analysis (available options: 'text', 'json'; defaults to 'text')

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