# Inspect memory usage using V8 heap snapshots (/docs/guides/runtime/heap-snapshot)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 203 · updated: 2026-07-28 -->
Related: [Install TypeScript declarations for Bun](/docs/guides/runtime/typescript.md), [Re-map import paths](/docs/guides/runtime/tsconfig-paths.md), [Debugging Bun with the VS Code extension](/docs/guides/runtime/vscode-debugger.md), [Debugging Bun with the web debugger](/docs/guides/runtime/web-debugger.md), [Build-time constants with --define](/docs/guides/runtime/build-time-constants.md), [Define and replace static globals & constants](/docs/guides/runtime/define-constant.md)

Bun implements V8's heap snapshot API. Use it to capture the heap at runtime and debug memory leaks in your JavaScript/TypeScript application.

```ts snapshot.ts icon="/icons/typescript.svg"
import v8 from "node:v8";

// Creates a heap snapshot file with an auto-generated name
const snapshotPath = v8.writeHeapSnapshot();
console.log(`Heap snapshot written to: ${snapshotPath}`);
```

***

## Inspect memory in Chrome DevTools [#inspect-memory-in-chrome-devtools]

To view V8 heap snapshots in Chrome DevTools:

1. Open Chrome DevTools (F12 or right-click and select "Inspect")
2. Go to the "Memory" tab
3. Click the "Load" button (folder icon)
4. Select your `.heapsnapshot` file

<Frame>
  ![Chrome DevTools Memory Tab](/docs/_assets/c9fc3e52b1052df828207c48c5e0eff03e3c94d56a24f54794ff3c509832af5e)
</Frame>
