Agent skill

Qwen Code Memory Leak Debugger

by QwenLM in QwenLM/qwen-code

Walks through capturing and comparing V8 heap snapshots to find memory leaks in the Qwen Code Node.js CLI, using tmux and the chrome-devtools CLI.

Apache-2.0Auto-check passedDevelopment

Install Qwen Code Memory Leak Debugger

skills CLI
$ npx skills add QwenLM/qwen-code --skill memory-leak-debug -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install QwenLM/qwen-code memory-leak-debug --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/QwenLM/qwen-code.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.qwen/skills/memory-leak-debug .claude/skills/memory-leak-debug && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
memory-leak-debug
GitHub stars
28k
Token cost
~1.3k tokens
SKILL.md length
494 words
Files
3 (incl. scripts)
Skills in repo
41
Repo updated
First seen
Licence
Apache-2.0

At a glance

Walks through capturing and comparing V8 heap snapshots to find memory leaks in the Qwen Code Node.js CLI, using tmux and the chrome-devtools CLI.

  • Works in 6 steps: Start the CLI with Snapshot Signal → Exercise the Suspected Leak → Start chrome-devtools Daemon → …
  • Investigating high or growing memory usage in the Qwen Code CLI
  • SKILL.md covers Prerequisites, Step 1: Start the CLI with…, Step 2: Exercise the Suspected… and Step 3: Start chrome-devtools…, plus 5 more sections
  • Runs Shell scripts from its folder; calls npm, bash and node

What it does

The agent starts the CLI under tmux with a heap-snapshot signal flag set, so it can drive the terminal UI from one pane and trigger snapshots from another without losing the session. It walks the process tree to find the real Node PID, since running through npm and tsx creates a chain of parent processes, and the PID discovery differs when profiling a built bundle directly.

Snapshots are taken at intervals with a kill signal, written to the working directory, and then loaded into the chrome-devtools CLI daemon for comparison of retained object sizes between the baseline and after-activity snapshots. A bundled script finds the leaf Node process in a tmux session, and an example walks through diagnosing a leak traced to the React reconciler's performance measurement.

When your agent uses it

  • Investigating high or growing memory usage in the Qwen Code CLI
  • Comparing heap snapshots before and after a suspected leaking action
  • Verifying that a production bundle's memory behavior matches the dev build

Example prompts

  • “Take two heap snapshots of the CLI before and after running a long chat session and compare them.”
  • “Find which objects are retained after switching sessions repeatedly.”
  • “Profile the production bundle to check whether tree-shaking removed the leaking code path.”

Requirements

  • Node.js 22 or newer
  • chrome-devtools CLI (chrome-devtools-mcp package)
  • tmux

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. Start the CLI with Snapshot Signal
  2. Exercise the Suspected Leak
  3. Start chrome-devtools Daemon
  4. Identify the Leak
  5. Identify Root Cause
  6. Verify Fix

What it can do on your machine

Read from SKILL.md and the folder at commit 55ee50d. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/ (Shell), which the agent can run.

    Shell commands in SKILL.md call:

    • npm
    • bash
    • node

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • github.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Qwen Code Memory Leak Debugger loads about 1.3k tokens when it runs. Until then it costs about 52 tokens; SKILL.md has 494 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~52
When it runs · the whole SKILL.md, loaded when a task matches
~1.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from QwenLM/qwen-code at commit 55ee50d, republished under its Apache-2.0 licence (© QwenLM). 494 words, ~1,319 tokens.

Download SKILL.mdSave it as .claude/skills/memory-leak-debug/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
memory-leak-debug
description
Diagnose memory leaks in the Qwen Code CLI using heap snapshots and the chrome-devtools CLI. Use when investigating high memory usage, unbounded growth, or suspected object retention issues.

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:

bash
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:

bash
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:

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

Step 2: Exercise the Suspected Leak

Drive the TUI via tmux (see tmux-real-user-testing skill for patterns). Take snapshots at intervals to compare:

bash
kill -USR2 $NODE_PID   # snapshot 1 (baseline)
# ... use the CLI via tmux send-keys ...
kill -USR2 $NODE_PID   # snapshot 2 (after activity)
# ... more activity ...
kill -USR2 $NODE_PID   # snapshot 3 (confirm growth trend)

Snapshots are written to the CLI's working directory as Heap.<timestamp>.<pid>.<seq>.heapsnapshot.

Step 3: Start chrome-devtools Daemon

bash
chrome-devtools start --experimentalMemory --headless --no-usage-statistics

This starts the daemon in file-analysis mode — no browser or live Node connection is needed. The memory tools work entirely on .heapsnapshot files.

Step 4: Identify the Leak

Load and summarize
bash
chrome-devtools load_memory_snapshot /abs/path/to/snapshot.heapsnapshot

Returns total heap size, V8 heap breakdown, node count.

Show full SKILL.md (201 more words)Show less
Get class-level aggregates with retained sizes
bash
chrome-devtools get_memory_snapshot_details /abs/path/to/snapshot.heapsnapshot

Output is CSV: uid, className, count, selfSize, maxRetainedSize.

Compare across snapshots to find classes whose count or retained size grows unboundedly.

Inspect instances of a leaking class
bash
chrome-devtools get_nodes_by_class /abs/path/to/snapshot.heapsnapshot <uid>

Where <uid> is from the get_memory_snapshot_details output. Returns individual instances with their id, retainedSize, and nodeIndex.

Trace retainer chains
bash
chrome-devtools get_node_retainers /abs/path/to/snapshot.heapsnapshot <nodeId>

Where <nodeId> is the id field from get_nodes_by_class. Shows what holds the object alive — follow the chain to find the root retention path.

Step 5: Identify Root Cause

Common patterns:

  • Unbounded buffer/array: An array that accumulates entries without eviction (e.g., performance.measure() → measureEntryBuffer).
  • Event listener leak: Listeners registered on long-lived emitters without cleanup.
  • Closure capture: A closure inadvertently captures a large object that outlives its intended scope.
  • Module-level cache: A Map/Set at module scope that grows with usage.

The retainer chain tells you what holds the object; the class aggregate growth rate tells you how fast it leaks.

Step 6: Verify Fix

After applying the fix:

  1. Rebuild: npm run bundle
  2. Repeat Steps 1-4 with the same workload.
  3. Confirm the leaking class count stabilizes (no longer grows with activity).

Cleanup

bash
HELPER=.qwen/skills/tmux-real-user-testing/scripts/tmux-real-user-log.sh
bash "$HELPER" finish "<session-name>" "<outdir>"
chrome-devtools stop
rm *.heapsnapshot  # if no longer needed

Worked Example

See examples/react-reconciler-performance-measure-leak.md for the ink 7 upgrade leak that caused ~143 MB retention from PerformanceMeasure objects.

© QwenLM, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files (scripts) in .qwen/skills/memory-leak-debug of QwenLM/qwen-code.

  • SKILL.md
  • examples/react-reconciler-performance-measure-leak.md
  • scripts/find-leaf-node.sh

Open the folder on GitHubat commit 55ee50d

Compare with similar skills

Qwen Code Memory Leak Debugger next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Qwen Code Memory Leak Debugger compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Qwen Code Memory Leak Debugger this skillQwenLM/qwen-code28k—~1.3kAutomated safety check: PassApache-2.0
Cmux Debugging Guidemanaflow-ai/cmux28k1 repos~1.1kAutomated safety check: PassCustom licence
AO Desktop App LauncherOrchestratorInc/agent-orchestrator13k—~2.4kAutomated safety check: PassApache-2.0
Electron Heap Snapshot Analysiskeybase/client9.3k—~875Automated safety check: PassBSD-3-Clause
Issue Fixmono/SkiaSharp5.6k—~5.1kAutomated safety check: PassMIT
PlotJuggler 4 Perf ProfilingPlotJuggler/PlotJuggler6.2k—~1.6kAutomated safety check: NotesMPL-2.0

Similar skills

  • Cmux Debugging Guide

    manaflow-ai/cmux

    Covers debug logging, the Debug menu, profiling rules and runtime pitfalls for working on the cmux macOS terminal app.

    28k GitHub starsUsed in 1 repo~1.1k tokens
    DevelopmentAuto-check passed
  • AO Desktop App Launcher

    OrchestratorInc/agent-orchestrator

    Launches, restarts and troubleshoots the real AO Electron desktop app from a checkout, with isolated or real local data and checks for stale processes.

    13k GitHub stars~2.4k tokensUpdated today
    DevelopmentAuto-check passed
  • Analyzes V8, Chrome and Electron .heapsnapshot files with Node scripts to find memory leaks, detached DOM nodes and the retainer paths that keep objects alive.

    9.3k GitHub stars~875 tokensUpdated today
    DevelopmentAuto-check passed
  • Issue Fix

    mono/SkiaSharp

    Fix bugs in SkiaSharp C bindings. An agent skill from mono/SkiaSharp.

    5.6k GitHub stars~5.1k tokensUpdated today
    DevelopmentAuto-check passed
  • PlotJuggler 4 Perf Profiling

    PlotJuggler/PlotJuggler

    Guides CPU profiling of PlotJuggler 4 on Linux with perf: count first, record cheaply with LBR, then read per-thread, flat, flamegraph or time-window views.

    6.2k GitHub stars~1.6k tokensUpdated 7 days ago
    DevelopmentAuto-check: notes
  • Analyzes Chrome or Electron DevTools Performance trace exports with Python scripts to find where render time actually goes, without opening DevTools.

    9.3k GitHub stars~809 tokensUpdated today
    DevelopmentAuto-check passed

More from QwenLM/qwen-code

All 41 skills in this repo
  • Reproduces a feature from Codex or Claude Code in Qwen Code by running the reference agent under capture, reading the traces, then implementing matching behavior.

    28k GitHub stars~1.5k tokensUpdated today
    Auto-check passed
  • Qwen Code E2E Testing

    QwenLM/qwen-code

    Guides end-to-end testing of the Qwen Code CLI in headless mode with real model calls, MCP test servers and inspection of raw API traffic.

    28k GitHub stars~2.1k tokensUpdated today
    Auto-check passed
  • Scheduled CI skill that scans a repository for small, certain docs, test and code hygiene issues and fixes them on one branch with a commit per finding.

    28k GitHub stars~1.7k tokensUpdated today
    Auto-check passed
  • Builds a rebranded Qwen Code desktop package from the Tauri shell using only a brand id and a logo, with sensible derived defaults.

    28k GitHub stars~2.1k tokensUpdated today
    Auto-check passed
  • tmux Real User Testing

    QwenLM/qwen-code

    Drives Qwen Code in a real tmux session the way a user would and saves a readable step-by-step transcript of each screen for maintainers to review.

    28k GitHub stars~2.3k tokensUpdated today
    Auto-check passed
  • Agent Reproduce Align

    QwenLM/qwen-code

    Runs a reference agent (Codex or Claude Code) and Qwen Code on the same scenario, captures HTTP and terminal traces, and compares them until behavior matches.

    28k GitHub stars~1.1k tokensUpdated today
    Auto-check passed

Categories

Questions about Qwen Code Memory Leak Debugger

What does Qwen Code Memory Leak Debugger do?

Walks through capturing and comparing V8 heap snapshots to find memory leaks in the Qwen Code Node.js CLI, using tmux and the chrome-devtools CLI. The agent starts the CLI under tmux with a heap-snapshot signal flag set, so it can drive the terminal UI from one pane and trigger snapshots from another without losing the session. It walks the process tree to find the real Node PID, since running through npm and tsx creates a chain of parent processes, and the PID discovery differs when profiling a built bundle directly.

When should I use Qwen Code Memory Leak Debugger?

Qwen Code Memory Leak Debugger fits situations like: investigating high or growing memory usage in the Qwen Code CLI; comparing heap snapshots before and after a suspected leaking action; verifying that a production bundle's memory behavior matches the dev build.

How do I install Qwen Code Memory Leak Debugger in Claude Code?

Run `npx skills add QwenLM/qwen-code --skill memory-leak-debug -a claude-code`. Or copy the skill folder (.qwen/skills/memory-leak-debug in QwenLM/qwen-code) into .claude/skills/memory-leak-debug in your project. Claude Code loads it when a task matches its description.

How do I install Qwen Code Memory Leak Debugger in Codex?

Run `npx skills add QwenLM/qwen-code --skill memory-leak-debug -a codex`. Or copy the skill folder (.qwen/skills/memory-leak-debug in QwenLM/qwen-code) into .agents/skills/memory-leak-debug in your project. Codex loads it when a task matches its description.

Can I use Qwen Code Memory Leak Debugger in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add QwenLM/qwen-code --skill memory-leak-debug -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/memory-leak-debug, .gemini/skills/memory-leak-debug, .github/skills/memory-leak-debug and .opencode/skills/memory-leak-debug in your project.

What does Qwen Code Memory Leak Debugger need to run?

Going by SKILL.md and its folder, Qwen Code Memory Leak Debugger needs a shell for the scripts in its folder and the command-line tools its instructions call (npm, bash and node). Our summary lists: Node.js 22 or newer; chrome-devtools CLI (chrome-devtools-mcp package); tmux.

Does Qwen Code Memory Leak Debugger access the network?

SKILL.md names 1 domain. As links in the text: github.com. This is read from the text; nothing was executed.

Is Qwen Code Memory Leak Debugger safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Qwen Code Memory Leak Debugger use?

Qwen Code Memory Leak Debugger is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Qwen Code Memory Leak Debugger use?

About 1.3k tokens (SKILL.md is roughly 5.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Qwen Code Memory Leak Debugger?

Skills that share tags, products or a category with Qwen Code Memory Leak Debugger: Cmux Debugging Guide (manaflow-ai/cmux, 28k stars), AO Desktop App Launcher (OrchestratorInc/agent-orchestrator, 13k stars), Electron Heap Snapshot Analysis (keybase/client, 9.3k stars) and Issue Fix (mono/SkiaSharp, 5.6k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Qwen Code Memory Leak Debugger?

QwenLM (a GitHub organization) maintains it in QwenLM/qwen-code, which has 28,370 GitHub stars. The repository holds 41 skills in this directory. The repository was last updated on October 9, 2026.

Source: QwenLM/qwen-code on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.