v8.startHeapProfile(options?): SyncHeapProfileHandle
Attributes
options:
ObjectsampleInterval?:
numberThe average sampling interval in bytes.
Default:
524288 (512 KiB).stackDepth?:
integerThe maximum stack depth for samples.
Default:
16.forceGC?:
booleanForce garbage collection before taking the profile.
Default:
false.includeObjectsCollectedByMajorGC?:
booleanInclude objects collected
by major GC. Default:
false.includeObjectsCollectedByMinorGC?:
booleanInclude objects collected
by minor GC. Default:
false.Returns:
SyncHeapProfileHandleStarting a heap profile then return a SyncHeapProfileHandle object.
This API supports using syntax.
const v8 = require('node:v8'); const handle = v8.startHeapProfile(); const profile = handle.stop(); console.log(profile);
import v8 from 'node:v8'; const handle = v8.startHeapProfile(); const profile = handle.stop(); console.log(profile);
With custom parameters:
const v8 = require('node:v8'); const handle = v8.startHeapProfile({ sampleInterval: 1024, stackDepth: 8, forceGC: true, includeObjectsCollectedByMajorGC: true, }); const profile = handle.stop(); console.log(profile);
import v8 from 'node:v8'; const handle = v8.startHeapProfile({ sampleInterval: 1024, stackDepth: 8, forceGC: true, includeObjectsCollectedByMajorGC: true, }); const profile = handle.stop(); console.log(profile);