sincecutoff.com
← all changes

analyze_heapsnapshot_contexts finds closure contexts retaining dead fields

Introduced 2026-10-15 · score 0.98

HOW TO USE IT

When diagnosing retained memory from a heap snapshot, use `analyze_heapsnapshot_contexts` to rank closure contexts holding dead captured fields; it requires `--memoryDebugging=true`. The retained-size score is a prioritizing heuristic, not an exact measure of reclaimable bytes.

analyze_heapsnapshot_contexts({"filePath":"<path-to-file.heapsnapshot>"})
analyze_heapsnapshot_contexts({"filePath":"<path-to-file.heapsnapshot>","pageIdx":0,"pageSize":20,"retainedSize":"1MB-2MB"})
analyze_heapsnapshot_contexts({"filePath":"<path-to-file.heapsnapshot>","scopeInfoNodeId":<scope-info-node-id>})

WHY THIS HELPS

When diagnosing retained memory from a heap snapshot, identify closure contexts holding dead captured variables.

REQUIREMENTS AND LIMITATIONS

  • Version: 1.11.0
  • filePath (required): Path to a `.heapsnapshot` file to read.
  • pageIdx: Zero-based page index; defaults to 0.
  • pageSize: Contexts returned per page; defaults to 20.
  • retainedSize: Inclusive range for the dead-field score (for example, `10KB`, `1MB-2MB`, `-1MB`, or `1MB-`); one value is treated as a minimum.
  • scopeInfoNodeId: Limit results to contexts declared by this ScopeInfo node ID, as reported in a previous call.
  • --memoryDebugging=true (required): Required server flag to enable this tool.
  • Prerequisite: Enable the MCP server flag `--memoryDebugging=true`.
  • Requires `--memoryDebugging=true`.
  • `filePath` must identify a `.heapsnapshot` file.
  • `pageIdx` defaults to 0; `pageSize` defaults to 20.
  • The retained-size score is a prioritizing heuristic, not an exact measure of reclaimable bytes.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card