v8.writeHeapSnapshot() writes the V8-managed heap to a .heapsnapshot file. Load that file into Chrome DevTools to investigate retained objects after the process has produced the evidence. section 11.1.3 section 11.1.4
Use the API when live debugger attachment is impractical or when programmatic capture fits the diagnostic workflow:
- Analyze the JSON-formatted file in DevTools rather than treating it as a human-readable report. section 11.1.4
- Expect a full garbage collection before writing; the snapshot represents objects that remain retained. section 11.1.4
- Prefer signal-triggered capture with --heapsnapshot-signal=SIGUSR2 when another terminal must initiate collection. section 11.1.4
Capturing a suspected leak
A growing array captured by an uncleared interval can retain SessionRecord objects indefinitely. Capture a snapshot, open it in DevTools, and follow the retainer chain backward from the records to the closure or container keeping them alive. section 11.1.4
