[vm] Add examples to heapsnapshot tool

Change-Id: I2b3735341146e532a747e302050e3983ee8f7e1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273240
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
Jens Johansen 2022-12-05 15:02:27 +00:00 committed by Commit Queue
parent 7a3aa5c7f5
commit 93ef21b00b

View file

@ -0,0 +1,67 @@
Examples:
# Load
load <file>
# Show named sets / known variables
info
# Find live objects
closure roots
# or give a name
all = closure roots
# Look into the object
stats all
# Filter lists from "all" into "lists"
lists = filter all _List
# Find empty lists into "empty-lists"
empty-lists = dfilter lists ==0
# Who's using the empty lists?
users empty-lists
# print that info (from $0 in this case as we didn't give it a name but it was
# the first one we didn't give a name)
stat $0
# Filter more
empty-growable-lists = filter (users empty-lists) _GrowableList
# Print
stats empty-growable-lists
# Who's using them?
retainers empty-growable-lists
# Look into strings next
strings = filter all String
# What's inside the strings
dstats strings
# Who's pointing to the big strings?
retainers (dfilter strings >=1024)
# Small strings
small-strings = dfilter strings <100
# See them
dstats small-strings
# Who's retaining the string "foo"
f = dfilter small-strings foo
retainters f
# Find stuff with specific field
hasField = filter all :specificField
stats closure hasField :specificField
foo = follow hasField :specificField
stats closure foo
# Stop the closure search if going into specific files
stats closure foo ^file1.dart ^file2.dart ^file3.dart