Skip to content

Instantly share code, notes, and snippets.

@mmarchini
Last active March 10, 2020 14:12
Show Gist options
  • Save mmarchini/303b1699d936d3649a09714be21e1263 to your computer and use it in GitHub Desktop.
Save mmarchini/303b1699d936d3649a09714be21e1263 to your computer and use it in GitHub Desktop.
V8 Heap Snapshot Schema

V8 Heap Snapshot Schema

Key Description
snapshot Metadata from the snapshot. See snapshot
nodes List of heap nodes. See nodes
edges List of heap edges between nodes. See edges
trace_function_infos ???
trace_tree ???
samples ???
strings List of string in the heap. See strings

snapshot

Key Description
meta A fixed object. Content may vary acording to V8 version
node_count Number of nodes in the snapshot
edge_count Number of edges in the snapshot
trace_function_count ???

nodes

List of integers, where each group of 6 consecutive numbers represents one node. A node is an object in the Heap.

Description
Node's type
Index to the string representing the name of this node
ID of this node
Size of this node
Number of childrens this node have
???

edges

List of integers, where each group of 3 consecutive numbers represents one edge. A edge is an object in the Heap.

Description
Edge's type
Can be a) index of this edge; b) index of the string name for this edge
ID of the node this edge points to

??? Question: how do we know the "from" of an edge? Is it determined by the list of nodes plus the childrens count for each node?

trace_function_infos

???

trace_tree

???

samples

????

strings

List with all strings in the heap.

Example

{
  "snapshot": {
    "meta": {
      "node_fields": [
        "type",
        "name",
        "id",
        "self_size",
        "edge_count",
        "trace_node_id"
      ],
      "node_types": [
        ["hidden","array","string","object","code","closure","regexp","number","native","synthetic","concatenated string","sliced string"],
        "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"
      ]
    },
    "node_count": 35968,
    "edge_count": 158089,
    "trace_function_count": 0
  },
  "nodes": [9, 1, 1, 0, 4, 0,
    // ...
    9, 1158, 2274944298, 0, 1, 0
  ],
  "edges":[1, 1, 6,
    // ...
    3, 178, 215796
  ],
  "trace_function_infos":[],
  "trace_tree":[],
  "samples":[],
  "strings":["<dummy>",
    "",
    // ...
    "bound_argument_2",
    "get listening"
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment