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
- Examples: V8 or hermes heap snapshot can be parsed by the getFullHeapFromFile API.
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
- Source:
fromNode: IHeapNode
returns an IHeapNode instance representing the hosting JS heap object where this reference starts
- Source:
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)
- Source:
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
- Source:
snapshot: IHeapSnapshot
get the IHeapSnapshot containing this JS reference
- Source:
toNode: IHeapNode
returns an IHeapNode instance representing the JS heap object pointed to by this reference
- Source:
to_node: number
the index of the JS heap object pointed to by this reference
- Source:
type: string
type of the JS reference, all types:
context
, element
, property
, internal
, hidden
, shortcut
, weak
- Source:
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.
- Returns:
AnyRecord
- Source:
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.
- Parameters:
...args
:any
[]
- Returns:
string
- Source: