function
generateHeapSnapshot
Generates a heap snapshot in JavaScriptCore's format. View it with bun --inspect or Safari's Web Inspector
Generates a V8 heap snapshot for use with Chrome DevTools or Visual Studio Code
Returns a JSON string you can save to a file.
const snapshot = Bun.generateHeapSnapshot("v8");
await Bun.write("heap.heapsnapshot", snapshot);Generates a V8 heap snapshot as an ArrayBuffer containing the UTF-8 encoded JSON.
This avoids the overhead of creating a JavaScript string for large heap snapshots.
const snapshot = Bun.generateHeapSnapshot("v8", "arraybuffer");
await Bun.write("heap.heapsnapshot", snapshot);Referenced types
interface HeapSnapshot
JavaScriptCore engine's internal heap snapshot format
For a snapshot Chrome DevTools can read, use generateHeapSnapshot with the "v8" format.
class ArrayBuffer
Represents a raw buffer of binary data, which is used to store data for the different typed arrays. ArrayBuffers cannot be read from or written to directly, but can be passed to a typed array or DataView Object to interpret the raw buffer as needed.