openclaw-test-heap-leaks
Skill59 starsChanged 16 days agoMITView on GitHub
Investigate OpenClaw pnpm test memory growth, Vitest OOMs, RSS spikes, and heap snapshot deltas.
We split this skill into the rules it gives an agent
15 rules. 7 are common, 3 are distinctive, and 5 are very specific to this project.
7
Common
Most of the 5 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Common: line 8
Use this skill for test-memory investigations.
- Very specific: line 10
Read ../openclaw-test-performance/SKILL.md first for the current test-performance commands and proof routing.
- Very specific: line 30
Run pnpm test:perf:profile:runner -- --output-dir .artifacts/test-perf/vitest-runner-profile -- <file> for a CPU profile plus a sampling …
- Very specific: line 32
When a dedicated harness or another known producer emits repeated .heapsnapshot files, compare snapshots from the same PID with …
- Distinctive: line 33
If no snapshot or heap profile is available, RSS growth is useful triage evidence, but keep the leak classification inconclusive.
- Very specific: line 36
If growth is dominated by Vite/Vitest transformed source strings, Module, system / Context, bytecode, descriptor arrays, or property maps, …
- Common: line 37
If growth is dominated by app objects, caches, buffers, server handles, timers, mock state, sqlite state, or similar runtime objects, treat …
- Common: line 38
If the names are ambiguous, stop short of a confident label and inspect retainers/dominators in DevTools for the top deltas.
- Very specific: line 46
Look for missing afterEach/afterAll, module-reset gaps, retained global state, unreleased DB handles, or listeners/timers that survive the …
- Common: line 48
Verify with the most direct proof.
- Distinctive: line 50
When a dedicated producer emits heap profiles or snapshots, repeat the same producer and compare equivalent artifacts.
- Common: line 55
Do not call everything a leak.
- Common: line 59
When the same retained object families grow across multiple intervals in the same worker PID, trust the snapshots over intuition, then …
- Distinctive: line 102
When fixing a different runtime leak, add a new harness alongside this one rather than retrofitting it.
- Common: line 108
When using this skill, report:
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
OpenClaw Test Heap Leaks
Use 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.
Read ../openclaw-test-performance/SKILL.md first for the current test-performance commands and proof routing.
For runtime fixes (e.g., closure leaks in long-running services like the gateway), see Validating runtime fixes below — that uses a dedicated harness rather than the unit-test profiling workflow.
Workflow
- Reproduce the failing shape first.
Match the real entrypoint and worker budget. For a broad unit-fast baseline with per-config max RSS and top-file timing, start with:
pnpm test:perf:groups \ --config test/vitest/vitest.unit-fast.config.ts \ --allow-failures \ --output .artifacts/test-perf/unit-fast-memory.json- For a suspected file, rerun that file with one worker and collect wall/RSS evidence:
/usr/bin/time -l pnpm test <file> --maxWorkers=1 --reporter=verbose. - Current
pnpm testexecution is planned byscripts/test-projects.mts. Record the printed Vitest config or shard and preserve that shape when the report is configuration- or worker-budget-specific.
- Collect the strongest available heap evidence.
- Run
pnpm test:perf:profile:runner -- --output-dir .artifacts/test-perf/vitest-runner-profile -- <file>for a CPU profile plus a sampling heap profile of the unit runner. Open the heap profile in DevTools and inspect the largest allocation families. - Sampling
.heapprofileoutput is not a.heapsnapshot; do not pass it to the snapshot delta helper. - When a dedicated harness or another known producer emits repeated
.heapsnapshotfiles, compare snapshots from the same PID with.agents/skills/openclaw-test-heap-leaks/scripts/heapsnapshot-delta.mjs. - If no snapshot or heap profile is available, RSS growth is useful triage evidence, but keep the leak classification inconclusive.
- Run
- Classify the growth before choosing a fix.
- If growth is dominated by Vite/Vitest transformed source strings,
Module,system / Context, bytecode, descriptor arrays, or property maps, treat it as likely retained module graph growth in long-lived workers. - If growth is dominated by app objects, caches, buffers, server handles, timers, mock state, sqlite state, or similar runtime objects, treat it as a likely cleanup or lifecycle leak.
- If the names are ambiguous, stop short of a confident label and inspect retainers/dominators in DevTools for the top deltas.
- If growth is dominated by Vite/Vitest transformed source strings,
- Fix the right layer.
- For likely retained transformed-module growth in shared workers:
- Inspect the owning Vitest config and the process chunking in
scripts/test-projects.test-support.mjs. Fix process lifetime or project ownership there only when the same-shape evidence shows that shared-worker retention is the cause. test/vitest/vitest.unit-fast-isolated.config.tsis for audited stateful tests that need a fresh module graph. Do not use it as a generic memory-hotspot list.- For real leaks:
- Patch the implicated test or runtime cleanup path.
- Look for missing
afterEach/afterAll, module-reset gaps, retained global state, unreleased DB handles, or listeners/timers that survive the file.
- Verify with the most direct proof.
- Re-run the same grouped or scoped command and confirm the max-RSS trend or OOM is reduced.
- When a dedicated producer emits heap profiles or snapshots, repeat the same producer and compare equivalent artifacts.
- For routing or config changes, verify the expected Vitest config or shard starts and the affected tests complete.
Heuristics
- Do not call everything a leak. Growth in a non-isolated shared Vitest project can be a worker-lifetime problem rather than an application object leak.
scripts/test-projects.mts,scripts/test-group-report.mts, andscripts/run-vitest-profile.mtsare the current execution, grouped-RSS, and profile entrypoints.- The
[test] starting ...lines identify the Vitest config or shard to reproduce. .artifacts/vitest-shard-timings.jsonstores config/shard durations for scheduling. It is not a file-level memory-hotspot or behavior manifest.- When the same retained object families grow across multiple intervals in the same worker PID, trust the snapshots over intuition, then confirm ambiguous calls with retainer evidence.
Snapshot Comparison
- Direct comparison:
node .agents/skills/openclaw-test-heap-leaks/scripts/heapsnapshot-delta.mjs before.heapsnapshot after.heapsnapshot
- Auto-select earliest/latest snapshots per PID within one lane:
node .agents/skills/openclaw-test-heap-leaks/scripts/heapsnapshot-delta.mjs --lane-dir <snapshot-directory>
- Useful flags:
--top 40--min-kb 32--pid 16133
Read the top positive deltas first. Large positive growth in module-transform artifacts points to shared-process lifetime or project ownership; 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.
Validating runtime fixes (not test-memory)
The workflow above is for diagnosing Vitest worker memory growth. For validating that a runtime/closure fix actually releases captured state, use the dedicated harness:
pnpm leak:embedded-run— runsscripts/embedded-run-abort-leak.ts. Loops N aborted runs in a function-shaped scope mimickingrunEmbeddedAttempt, writes heap snapshots, and reports a PASS/FAIL verdict on retention growth usingFinalizationRegistryfor tracked-instance counting plus RSS delta.
Modes:
closure-extracted(default) — production fix shape (helper at module scope).closure-inline— pre-fix shape (closure inside the runner scope). Use as a sensitivity check: if it passes you've broken the harness, not fixed a bug.synthetic-leak— deliberately retains via a module-level bucket. Use to confirm the harness can detect leaks before trusting a PASS on a real fix.
Snapshots land in .tmp/embedded-run-abort-leak/. Diff with the same script
as above:
node .agents/skills/openclaw-test-heap-leaks/scripts/heapsnapshot-delta.mjs \
.tmp/embedded-run-abort-leak/baseline-*.heapsnapshot \
.tmp/embedded-run-abort-leak/batch-N-*.heapsnapshot --top 30When fixing a different runtime leak, add a new harness alongside this one rather than retrofitting it. The fixture function should mimic the lexical scope of the function where the leak lives, not be a generic abort-loop.
Output Expectations
When using this skill, report:
- The exact reproduce command.
- Which Vitest config or target was reproduced, and which PID was compared when snapshots were available.
- The dominant retained object families from the heap profile or snapshot delta, when available.
- Whether the issue is a likely real leak or likely shared-worker retained module growth, plus whether retainers/dominators confirmed it.
- The concrete fix or impact-reduction patch.
- What you verified, and what snapshot overhead prevented you from verifying.
Other versions14 projects use a version of this.
Word for word · 9
- steipete/warelay★ 394k100% same
- moltbot/clawdbot★ 394k100% same
- moltbot/moltbot★ 394k100% same
- clawdbot/clawdbot★ 394k100% same
- steipete/clawdis★ 394k100% same
- openclaw/openclaw★ 394k100% same
- molt-bot/clawdbot★ 391k100% same
- friuns2/openclaw-android-assistant★ 573100% same
- OpenClawAndroid/openclaw-android-assistant★ 556100% same
Edited · 5
- OpenBMB/EdgeClaw★ 1.2k40% same
- AtomicBot-ai/atomicbot★ 32540% same
- QVerisAI/QVerisBot★ 18440% same
- clawsouls/soulclaw★ 955% same
- supermansuper563-ops/openclaw-workbench★ 055% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository107 other files it gives its agents.
- AGENTS.mdAGENTS.md
- docs/AGENTS.mdAGENTS.md
- extensions/AGENTS.mdAGENTS.md
- scripts/AGENTS.mdAGENTS.md
- test/AGENTS.mdAGENTS.md
- ui/AGENTS.mdAGENTS.md
- agent-transcriptSkill
- auto-qaSkill
- autoreviewSkill
- channel-message-flowsSkill
- clawdtributorSkill
- claw-scoreSkill
- clawsweeperSkill
- control-ui-e2eSkill
- crabboxSkill
- discord-clawdSkill
- discord-e2eSkill
- discord-user-postSkill
- discrawlSkill
- gitcrawlSkill
- graincrawlSkill
- notcrawlSkill
- openclaw-changelog-updateSkill
- openclaw-ci-limitsSkill
- openclaw-debuggingSkill
- openclaw-docker-e2e-authoringSkill
- openclaw-ghsa-maintainerSkill
- openclaw-live-updaterSkill
- openclaw-parallels-smokeSkill
- openclaw-pr-maintainerSkill
- openclaw-qa-testingSkill
- openclaw-refactor-docsSkill
- openclaw-release-validationSkill
- openclaw-repair-sweepSkill
- openclaw-secret-scanning-maintainerSkill
- openclaw-testingSkill
- openclaw-test-performanceSkill
- openclaw-updateSkill
- parallels-discord-roundtripSkill
- plugin-sdk-impactSkill
- proof-videoSkill
- prototype-openclaw-tuiSkill
- pr-simplifySkill
- release-openclaw-announcementSkill
- release-openclaw-ciSkill
- release-openclaw-macSkill
- release-openclaw-maintainerSkill
- release-openclaw-plugin-testingSkill
- security-triageSkill
- slack-e2eSkill
- slacrawlSkill
- solidSkill
- tag-duplicate-prs-issuesSkill
- technical-documentationSkill
- telegram-e2e-userbotSkill
- test-auditSkill
- update-team-serverSkill
- verify-releaseSkill
- 1passwordSkill
- apple-notesSkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

