FstartHeapProfile
Bun

function

v8.startHeapProfile

Starting a heap profile then return a SyncHeapProfileHandle object. This API supports using syntax.

import v8 from 'node:v8';

const handle = v8.startHeapProfile();
const profile = handle.stop();
console.log(profile);

With custom parameters:

import v8 from 'node:v8';

const handle = v8.startHeapProfile({
  sampleInterval: 1024,
  stackDepth: 8,
  forceGC: true,
  includeObjectsCollectedByMajorGC: true,
});
const profile = handle.stop();
console.log(profile);

Referenced types

interface HeapProfileOptions

interface SyncHeapProfileHandle

  • Stopping collecting the profile and the profile will be discarded.

  • stop(): string;

    Stopping collecting the profile and return the profile data.