Skip to content

Add opt-in heap snapshot and bounded memory timeline diagnostics #4183

@qqqys

Description

@qqqys

Parent

Part of #3000 and follows #4179.

Goal

Add an explicit advanced diagnostic path for heap snapshots and short memory timelines, so maintainers can ask users for stronger evidence when /doctor memory indicates high pressure.

Motivation

Single snapshots cannot distinguish transient compression peaks from sustained leaks. Heap snapshots and short trend sampling should be available, but they must be opt-in because they can be large and may contain sensitive strings from the process heap.

Proposed solution

  • Add an opt-in heap snapshot command, for example /doctor memory --heap-snapshot.
  • Use Node/V8 snapshot support such as v8.writeHeapSnapshot() where available.
  • Save artifacts under a diagnostics directory, for example .qwen/diagnostics/memory/<timestamp>/ or an equivalent storage path.
  • Write a lightweight JSON/text diagnostics report before the heap snapshot so the artifact bundle has context.
  • Add a short memory timeline mode, for example /doctor memory --watch <seconds> or a bounded sampling helper, reporting RSS/heap/external deltas.
  • Print a clear privacy warning before/with heap snapshot output.

Non-goals

  • No automatic background heap dumps without explicit user action.
  • No uploading artifacts anywhere.
  • No parsing heap snapshots inside Qwen Code yet.
  • No memory-pressure guard in this issue.

Acceptance criteria

  • Heap snapshot generation is opt-in and degrades gracefully if unsupported.
  • Output includes artifact paths and privacy guidance.
  • Watch/timeline mode is bounded and cannot run indefinitely.
  • Tests cover option parsing, unavailable V8 behavior, and path/report formatting.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions