Skip to main content

Interface: IHeapLocation

An IHeapLocation instance contains a source location information associated with a JS heap object. 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 IHeapLocation instance

import type {IHeapSnapshot, IHeapNode, IHeapLocation} 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 node (heap object)
heap.nodes.forEach((node: IHeapNode, i: number) => {
const location: Nullable<IHeapLocation> = node.location;
if (location) {
// use the location API here
location.line;
// ...
}
});
})();

Properties

column: number

get the column number


line: number

get the line number


node: Nullable<IHeapNode>

get the heap object this location this location represents


script_id: number

get the script ID of the source file


snapshot: IHeapSnapshot

get the IHeapSnapshot containing this location instance

Methods

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.

  • Properties
    • column: number
    • line: number
    • node: Nullable<IHeapNode>
    • script_id: number
    • snapshot: IHeapSnapshot
  • Methods
    • toJSONString(...args)