hubcap heapsnapshot - Capture a V8 heap snapshot

When to use

Capture a V8 heap snapshot for memory analysis. Open the output file in Chrome DevTools Memory panel to inspect object allocations and track memory leaks. Use metrics for a quick heap size check without generating a full snapshot.

Usage

hubcap heapsnapshot --output <file>

Arguments

None.

Flags

FlagTypeDefaultDescription
--outputstring""Output file path (required)

Output

FieldTypeDescription
filestringPath to the written snapshot file
sizeintFile size in bytes
{"file":"heap.json","size":12345}

Errors

ConditionExit codeStderr
Chrome not connected2error: connecting to Chrome: ...
Missing —output flag1error: --output flag is required
Cannot write to file1error: cannot write to "<path>"
Timeout during capture3error: timeout

Examples

Capture a heap snapshot:

hubcap heapsnapshot --output heap.json

Capture a snapshot and report its size:

hubcap heapsnapshot --output heap.json | jq '.size'

Compare heap size before and after an action:

hubcap heapsnapshot --output before.json
hubcap goto "https://example.com/heavy-page"
hubcap heapsnapshot --output after.json

Take a snapshot and check quick metrics in one pipeline:

hubcap heapsnapshot --output "heap-$(date +%s).json" && hubcap metrics | jq '.JSHeapUsedSize'

See also

  • trace - Capture a Chrome performance trace
  • metrics - Get page performance metrics