memory-leak-debug

memory-leak-debug is a skill for Claude Code, Codex from QwenLM/qwen-code. It costs 42 tokens per session (1,324 once invoked), scanned A, original, Apache-2.0.

A process for investigating whether the Qwen Code command-line program is using more memory over time than it should. It uses Node.js memory snapshots to show which objects remain in memory.

In plain words
What is it for?
It captures and compares heap snapshots, then examines retained memory with Chrome DevTools command-line tools.
Why use it?
It helps find objects that are accidentally retained, causing memory usage to grow during long-running or repeated work.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/qwenlm/qwen-code/memory-leak-debug
Any agent
npx skills add QwenLM/qwen-code --skill memory-leak-debug
Clone the repo
git clone --depth 1 https://github.com/QwenLM/qwen-code

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for memory-leak-debug

README.md
[![agentmods](https://agentmods.dev/badge/skills/qwenlm/qwen-code/memory-leak-debug.svg)](https://agentmods.dev/skills/qwenlm/qwen-code/memory-leak-debug)
Your own site
<a href="https://agentmods.dev/skills/qwenlm/qwen-code/memory-leak-debug"><img src="https://agentmods.dev/badge/skills/qwenlm/qwen-code/memory-leak-debug.svg" alt="Measured on agentmods" height="20"></a>
Per session 42 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,324 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00042 $0.01324
Opus 5 $0.00021 $0.00662
Sonnet 5 $0.00008 $0.00265
Haiku 4.5 $0.00004 $0.00132

Measured 4d ago against content hash b1e8fda9850f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

memory-leak-debug scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/find-leaf-node.sh), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.qwen/skills/memory-leak-debug/SKILL.md · 162 lines

How it starts

The opening of the file, as written. The whole thing — 162 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Memory Leak Debugging

Diagnose memory leaks in the Qwen Code Node.js CLI by capturing heap snapshots and analyzing retained object sizes via chrome-devtools CLI tooling.

Prerequisites

Step 1: Start the CLI with Snapshot Signal

Use tmux so you can interact with the TUI and trigger snapshots from another pane. Use the tmux-real-user-testing helper script:

HELPER=.qwen/skills/tmux-real-user-testing/scripts/tmux-real-user-log.sh
eval "$(bash "$HELPER" start memleak . \
  env QWEN_CODE_NO_RELAUNCH=true NODE_OPTIONS=--heapsnapshot-signal=SIGUSR2 \
  npm run dev)"
echo "SESSION=$SESSION OUTDIR=$OUTDIR"

The eval exports SESSION and OUTDIR. Note: shell environment does not persist across separate tool calls — save the session name from the output and use it explicitly in subsequent commands.

Notes:

  • npm run dev runs from TypeScript source via tsx — no build step needed and changes to core/cli are reflected immediately.
  • QWEN_CODE_NO_RELAUNCH=true prevents the CLI from spawning a child process, so PID management is simpler.
  • NODE_OPTIONS propagates the flag through npm → tsx → node.

Get the PID of the actual node process. With npm run dev, there's a process chain (npm → node scripts/dev.js → tsx → node CLI), so walk the tree to the innermost node child:

NODE_PID=$(bash .qwen/skills/memory-leak-debug/scripts/find-leaf-node.sh "<session-name>")

To profile the production bundle instead (e.g., verifying tree-shaking): npm run bundle first, then use env QWEN_CODE_NO_RELAUNCH=true node --heapsnapshot-signal=SIGUSR2 dist/cli.js as the command. Since node is the direct pane process, PID discovery is simpler:

NODE_PID=$(tmux list-panes -t "<session-name>" -F '#{pane_pid}')

Read the full file on GitHub · 162 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 162 lines · 42 tokens per session scan A b1e8fda9850f

Subscribe to this mod's changes

memory-leak-debug is a skill published in the GitHub repository QwenLM/qwen-code (27,620 stars, last pushed today), licensed Apache-2.0. It adds 42 tokens to every session and 1,324 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.