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
- Examples: V8 or hermes heap snapshot can be parsed by the getFullHeapFromFile API.
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
- Source:
line: number
get the line number
- Source:
node: Nullable
<IHeapNode
>
get the heap object this location this location represents
- Source:
script_id: number
get the script ID of the source file
- Source:
snapshot: IHeapSnapshot
get the IHeapSnapshot containing this location instance
- 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: