


























@@ -7,6 +7,8 @@ description: Investigate OpenClaw pnpm test memory growth, Vitest OOMs, RSS spik
7788Use this skill for test-memory investigations. Do not guess from RSS alone when heap snapshots are available. Treat snapshot-name deltas as triage evidence, not proof, until retainers or dominators support the call.
9910+For **runtime fixes** (e.g., closure leaks in long-running services like the gateway), see [Validating runtime fixes](#validating-runtime-fixes-not-test-memory) below — that uses a dedicated harness, not the test-parallel snapshot machinery.
11+1012## Workflow
111312141. Reproduce the failing shape first.
@@ -63,6 +65,38 @@ Use this skill for test-memory investigations. Do not guess from RSS alone when
63656466Read the top positive deltas first. Large positive growth in module-transform artifacts suggests lane isolation; large positive growth in runtime objects suggests a real leak. If the names alone do not settle it, open the same snapshot pair in DevTools and inspect retainers/dominators for the top rows before declaring root cause.
656768+## Validating runtime fixes (not test-memory)
69+70+The workflow above is for diagnosing Vitest worker memory growth. For
71+validating that a runtime/closure fix actually releases captured state, use the
72+dedicated harness:
73+74+- `pnpm leak:embedded-run` — runs `scripts/embedded-run-abort-leak.ts`. Loops N
75+ aborted runs in a function-shaped scope mimicking `runEmbeddedAttempt`,
76+ writes heap snapshots, and reports a PASS/FAIL verdict on retention growth
77+ using `FinalizationRegistry` for tracked-instance counting plus RSS delta.
78+79+Modes:
80+81+- `closure-extracted` (default) — production fix shape (helper at module scope).
82+- `closure-inline` — pre-fix shape (closure inside the runner scope). Use as a
83+ sensitivity check: if it passes you've broken the harness, not fixed a bug.
84+- `synthetic-leak` — deliberately retains via a module-level bucket. Use to
85+ confirm the harness can detect leaks before trusting a PASS on a real fix.
86+87+Snapshots land in `.tmp/embedded-run-abort-leak/`. Diff with the same script
88+as above:
89+90+```
91+node .agents/skills/openclaw-test-heap-leaks/scripts/heapsnapshot-delta.mjs \
92+ .tmp/embedded-run-abort-leak/baseline-*.heapsnapshot \
93+ .tmp/embedded-run-abort-leak/batch-N-*.heapsnapshot --top 30
94+```
95+96+When fixing a different runtime leak, add a new harness alongside this one
97+rather than retrofitting it. The fixture function should mimic the lexical
98+scope of the function where the leak lives, not be a generic abort-loop.
99+66100## Output Expectations
6710168102When using this skill, report:
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。