Skip to main content

Interface: IHeapEdge

An IHeapEdge instance represents a JS reference in a heap snapshot. A heap snapshot is generally a graph where graph nodes are JS heap objects and graph edges are JS references among JS heap objects.

readonly it is not recommended to modify any IHeapEdge instance

import type {IHeapSnapshot, IHeapEdge} from '@memlab/core';
import {dumpNodeHeapSnapshot} from '@memlab/core';
import {getFullHeapFromFile} from '@memlab/heap-analysis';

(async function () {
const heapFile = dumpNodeHeapSnapshot();
const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);

// iterate over each edge (JS reference in heap)
heap.edges.forEach((edge: IHeapEdge, i: number) => {
// use the heap edge APIs here
const nameOrIndex = edge.name_or_index;
// ...
});
})();

Hierarchy

  • IHeapEdgeBasic

    IHeapEdge

Properties

edgeIndex: number

index of this JS reference inside the edge.snapshot.edges pseudo array


fromNode: IHeapNode

returns an IHeapNode instance representing the hosting JS heap object where this reference starts


is_index: boolean

if true, means this is a reference to an array element or internal table element (edge.name_or_index will return a number), otherwise this is a reference with a string name (edge.name_or_index will return a string)


name_or_index: string | number

name of the JS reference. If this is a reference to an array element or internal table element, it is an numeric index


snapshot: IHeapSnapshot

get the IHeapSnapshot containing this JS reference


toNode: IHeapNode

returns an IHeapNode instance representing the JS heap object pointed to by this reference


to_node: number

the index of the JS heap object pointed to by this reference


type: string

type of the JS reference, all types: context, element, property, internal, hidden, shortcut, weak

Methods

getJSONifyableObject()

convert to a concise readable object that can be used for serialization (like calling JSON.stringify(node, ...args)).

This API does not contain all the information captured by the hosting object.


toJSONString(...args)

convert to a concise readable string output (like calling JSON.stringify(node, ...args)).

Note: Please be aware that using JSON.stringify(node, ...args) is not recommended as it will generate a JSON representation of the host object that is too large to be easily readable due to its connections to other parts of the data structures within the heap snapshot.

This API does not completely serialize all the information captured by the hosting object.

  • Hierarchy
  • Properties
    • edgeIndex: number
    • fromNode: IHeapNode
    • is_index: boolean
    • name_or_index: string | number
    • snapshot: IHeapSnapshot
    • toNode: IHeapNode
    • to_node: number
    • type: string
  • Methods
    • getJSONifyableObject()
    • toJSONString(...args)