v8.startHeapProfile([options])
options<Object>- 返回:SyncHeapProfileHandle
启动堆分析然后返回一个 SyncHeapProfileHandle 对象。
此 API 支持 using 语法。
🌐 Starting 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);