Add compact JS heap leak report command
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 48/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- react-native, typescript
- Ambito
- cli, devtools, performance
Direzione di ricerca
Inizia individuando i punti di ingresso dei comandi esistenti per memory usage, snapshot e allocation e verifica come producono dati sample, diff, leak-triplet e retainer. Definisci l’interfaccia del report con limiti, la classificazione e il filtraggio dei sospetti, le etichette delle evidenze e l’output compatto, quindi verifica che i comandi esistenti rimangano invariati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
agent-cdp already exposes the primitives needed to identify JavaScript heap leaks:
memory usage sample|diff|leak-signalmemory snapshot capture|diff|leak-tripletmemory snapshot classes|instances|retainersmemory allocation start|stop|hotspots
For an agent workflow, the user still has to run several commands and synthesize the final leak finding manually. That works, but it is more verbose than necessary and makes agents choose between multiple partially overlapping commands.
This came up while integrating React Native/Metro CDP support for agent-device: we want agent-device to expose agent-cdp narrowly for JS heap leaks, while keeping React rendering under agent-react-devtools and native/process memory under agent-device perf memory.
Related transport PR: https://github.com/callstackincubator/agent-cdp/pull/30
Current output
The existing command outputs are useful individually.
Heap usage sample:
jm_1 (baseline) used:14.17 MB total:20.00 MB gc at 2026-06-25 13:31:01
Heap usage diff:
jm_1 → jm_2: used 14.17 MB→23.88 MB (+9.71 MB +68.53%) total 20.00 MB→32.00 MB (+12.00 MB)
Snapshot diff:
ms_1 → ms_2
~ JSObject(Dictionary) object +0 +0 B +9.71 MB
~ JSArray object +1 +80 B +9.71 MB
~ (string) string +20002 +7.93 MB +7.93 MB
+ JSObject(tag, index, payload) object +20000 +1.53 MB +9.46 MB
+ __agentDeviceIntentionalLeak symbol +1 +4 B +4 B
Leak triplet:
ms_1 → ms_2 → ms_3
JSObject(Dictionary) object 5.12 MB 14.83 MB 14.83 MB 1.00
JSArray object 3.70 MB 13.41 MB 13.41 MB 1.00
JSObject(tag, index, payload) object 0 B 9.46 MB 9.46 MB 1.00
Retainers:
[object] JSArray (id=478047) .[0]
[object] JSObject(Dictionary) (id=83) .__agentDeviceIntentionalLeak
[synthetic] (RuntimeFields) (id=13) .[0]
[synthetic] (GC roots) (id=3) .[4]
These are enough to identify the leak, but an agent has to combine them into a human finding.
Proposed change
Add a compact leak report command that combines the useful pieces into one bounded report.
Possible interface:
agent-cdp memory leak report --baseline ms_1 --action ms_2 --cleanup ms_3 --limit 5
Optional convenience workflow for usage checkpoints:
agent-cdp memory leak signal --baseline jm_1 --action jm_2 --cleanup jm_3
I would keep this under memory leak or memory snapshot leak-report, rather than expanding CPU/profile/trace scope.
Desired output
Default output should be intentionally small and agent-friendly:
JS heap leak signal: high
Snapshots: ms_1 baseline → ms_2 after-action → ms_3 cleanup
Retained heap: 80.05 MB → 89.77 MB → 89.77 MB
Top retained suspects:
1. JSObject(tag, index, payload)
+20,000 instances, +9.46 MB retained, persistence 1.00
retained by: globalThis.__agentDeviceIntentionalLeak → GC roots
confidence: high (growth persisted after cleanup; retaining path found)
2. (string)
+20,002 instances, +7.93 MB retained, persistence 1.00
retained by: JSObject(tag, index, payload).payload
confidence: medium (payload of top suspect)
Next: inspect code writing __agentDeviceIntentionalLeak.
Selection and filtering recommendations
- Rank suspects by retained delta that persists from action to cleanup.
- Prefer app-owned names/paths when source/module information is available.
- Group framework/runtime noise separately: React Native, Hermes/runtime internals, Expo shell, native/synthetic roots.
- Include the shortest useful retaining path for each suspect, not every retainer.
- Include confidence/evidence labels such as:
- heap grew after action
- growth persisted after cleanup
- GC was requested
- retaining path found
- source/module attribution available
- Keep raw snapshots and large allocation profiles as artifacts, not terminal output.
Why this matters
For AI agents and CLI users, this would turn a multi-command investigation into a clear diagnosis surface. It also avoids overlap with React DevTools:
- React/component render problems stay in
agent-react-devtools - Native/process memory stays in platform tooling
agent-cdpbecomes the clear owner for JavaScript heap leak evidence
Compatibility
This can be additive. Existing memory usage, memory snapshot, and memory allocation commands do not need to change.
- Lingua principale
- TypeScript
- Stelle
- 61
- Fork
- 4
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Issue simili
-
VS Code extension: clickable file links in chat drop the :line suffix, never jump to the lineAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
MoonshotAI/kimi-code#4398 ·
I maintainer di solito rispondono entro 1 giorno
-
Xiaomi Mimo语音识别服务异常Apertapending triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
package-lock.json : les binaires natifs macOS et Linux de unrs-resolver ont disparu depuis #1823Apertabug dependencies
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
AxaFrance/design-system#2064 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100