Interface: IHeapEdges
A pseudo array containing all heap graph edges (references to heap objects in heap). A JS heap could contain millions of references, so memlab uses a pseudo array as the collection of all the heap edges. The pseudo array provides API to query and traverse all heap references.
readonly
modifying this pseudo array is not recommended
- Examples:
import type {IHeapSnapshot, IHeapEdges} 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);
const edges: IHeapEdges = heap.edges;
edges.length;
edges.get(0);
edges.forEach((edge, i) => {
if (stopIteration) {
return false;
}
});
})();
Properties
length: number
The total number of edges in heap graph (or JS references in heap snapshot).
- Source:
Methods
forEach(callback
)
Iterate over all array elements and apply the callback to each element in ascending order of element index.
- Parameters:
callback
: (edge
:IHeapEdge
,index
:number
) =>boolean
|void
| the callback does not need to return any value, if the callback returnsfalse
when iterating on element at indexi
, then all elements afteri
won't be iterated.
- Returns:
void
- Source:
get(index
)
get an IHeapEdge element at the specified index
Parameters:
index
:number
| the index of an element in the pseudo array, the index ranges from 0 to array length - 1. Notice that this is not the heap node id.
Returns:
Nullable
<IHeapEdge
> | When 0 <=index
< array.length, this API returns the element at the specified index, otherwise it returnsnull
.Source: