Using selenium, I took memory snapshot of a website with driver.execute_script(":takeHeapSnapshot") and extracted its metadata:
{
"snapshot": {
"meta": {
"node_fields": [
"type", "name", "id", "self_size", "edge_count", "trace_node_id", "detachedness"
],
"node_types": [
["hidden", "array", "string", "object", "code", "closure", "regexp", "number", "native", "synthetic", "concatenated string", "sliced string", "symbol", "bigint"],
"string", "number", "number", "number", "number", "number"
],
"edge_fields": [
"type", "name_or_index", "to_node"
],
"edge_types": [
["context", "element", "property", "internal", "hidden", "shortcut", "weak"],
"string_or_number", "node"
],
"trace_function_info_fields": [
"function_id", "name", "script_name", "script_id", "line", "column"
],
"trace_node_fields": [
"id", "function_info_index", "count", "size", "children"
],
"sample_fields": [
"timestamp_us", "last_assigned_id"
],
"location_fields": [
"object_index", "script_id", "line", "column"
]
},
"node_count": 6182075,
"edge_count": 17793245,
"trace_function_count": 0
}
}
Can someone explain, please, what each field means and how to use that information to extract data? What are nodes, edges, location fields etc. As example, let's say, I have an ArrayBuffer on heap the size of which I know (and it's unique) and I want to retrieve this array. Is it possible to do with the snapshot?
meta fields group explains the content of the different arrays of the snapshot.
The snapshot has the nodes array. This array has 7 numbers for every node in the heap and node_fields array describes the meaning for all of these 7 numbers.
at the same time node_types array describes the types for these 7 numbers. For example if you have the next 7 numbers in the nodes array [ ....., 2, 9, 13, 42, 0, 0, 0, ......
then the Nth node in the heap
The edges array has a triplet of numbers for the every edge and you could see the names of every number in the edges_fields and the types in the edge_types array. For example the triplet 2, 17, 79 in the edges array at the offset 0 means:
I hope this explanation could give you some light how to understand the content of the heap snapshot.