Guide · Agent skill
How to use the Memory Leak Debugger for Qwen Code agent skill
Updated · written with AI from the project's own documentation and checked against our catalogue data
The memory-leak-debug skill is an agent skill that teaches an AI coding agent a fixed method for finding memory leaks in the Qwen Code command-line tool. It is written for contributors to the Qwen Code repository who suspect high or growing memory use. After reading this guide you will know how to install the skill, how to ask an agent to use it, what the agent does at each step, and what you need on your machine first.
Quick start
- 1Install the skill. Download the ZIP from this page and unzip it into ~/.claude/skills/ or a project's .claude/skills/ folder, or upload the ZIP under Settings, Capabilities, Skills in the Claude apps.
- 2Check the requirements. Confirm Node.js 22 or newer, tmux, and the chrome-devtools CLI are available. The agent offers to install chrome-devtools globally with npm only after you confirm.
- 3Ask for an investigation. Describe the symptom, such as memory growing during long CLI sessions, and name the Qwen Code repository so the agent picks the skill.
- 4Capture snapshots during activity. The agent starts the CLI in tmux with the snapshot signal and sends SIGUSR2 at several points while you exercise the suspected leak.
- 5Compare and trace the leak. The agent loads the snapshots, compares class counts and retained sizes, and traces retainer chains for the class that keeps growing.
- 6Verify the fix. After a fix, rebuild and repeat the same workload, then confirm the leaking class count stops growing.
What does the memory-leak-debug skill make the agent do?
The skill sets out a step-by-step leak investigation. The agent starts the Qwen Code CLI in a tmux terminal session with a flag that lets it save V8 heap snapshots on a signal. It then sends that signal at several points during a workload, so you get a series of snapshots taken over time.
The agent loads those snapshots with the chrome-devtools command-line tool, compares which object classes grow in count or retained size, and traces what keeps the growing objects alive. From that it suggests likely root causes and how to verify a fix by rerunning the same workload.
- Captures snapshots at a baseline and after activity, to show a growth trend
- Lists class-level counts and retained sizes, and compares them across snapshots
- Traces retainer chains to show what holds an object in memory
- Suggests common causes such as unbounded arrays, listener leaks, closures and module-level caches
How do you install the memory-leak-debug skill?
Download the skill ZIP from this page and unzip it. Put the resulting folder in ~/.claude/skills/ to make it available across your projects, or in a project's .claude/skills/ folder to limit it to that project.
If you use the Claude apps instead, open Settings, go to Capabilities, then Skills, and upload the ZIP there.
The skill folder contains SKILL.md, a scripts/ folder with find-leaf-node.sh, and an examples/ folder with a worked example. The SKILL.md commands refer to .qwen/skills/ paths, which match the layout of the Qwen Code repository, so check the paths before running them in another project.
What do you need before you start?
The skill lists these requirements. Check each one before you ask the agent to run an investigation.
- Node.js 22 or newer, because the heap snapshot signal flag needs it
- The chrome-devtools CLI from the chrome-devtools-mcp npm package. If it is missing, the agent offers to install it globally with npm, and only after you confirm
- tmux, which the agent uses to run the CLI in a session you can drive
- The tmux-real-user-testing helper skill from the same repository. The source references it but does not include it in the provided files, so you may need to get it from the repository separately
npm i chrome-devtools-mcp@latest -gHow do you trigger the skill with a natural request?
You do not need a special command. Describe the symptom in plain language and the agent should match it to the skill. The skill description says it applies when you are investigating high memory usage, unbounded growth, or suspected object retention issues.
Good requests name the symptom and the repository, for example asking the agent to check whether memory keeps growing while you use the Qwen Code CLI in this repo. Naming the workload helps the agent choose what to exercise between snapshots.
- Memory keeps climbing during long sessions in the CLI. Can you find the leak?
- Heap usage is high after many renders. Use the memory-leak-debug skill to find which objects are retained.
- Check whether the number of PerformanceMeasure objects grows as I use the TUI.
What does a typical investigation look like?
The agent starts the CLI in tmux with the snapshot signal enabled, finds the innermost node process, takes snapshots during activity, and then analyses them. The core commands come from the skill's own steps.
Snapshots are written to the CLI's working directory as Heap.timestamp.pid.seq.heapsnapshot files. Compare the class aggregates across snapshots first, then inspect instances of the class that grows, then follow its retainer chain to the root.
- Take a snapshot after the baseline, after activity and after more activity
- Load each snapshot and compare class counts and maxRetainedSize in the CSV output
- Use get_nodes_by_class with a class uid, then get_node_retainers with a node id
chrome-devtools get_node_retainers /abs/path/to/snapshot.heapsnapshot <nodeId>How do you verify a fix and clean up?
After you apply a fix, rebuild with npm run bundle, repeat the same snapshot workflow with the same workload, and confirm the leaking class count stops growing with activity. The worked example in the skill shows a leak in PerformanceMeasure objects that grew from 184 to about 150,700 instances over a session of normal use.
When you finish, the skill's cleanup steps close the tmux session, stop the chrome-devtools daemon and remove snapshot files you no longer need. Delete snapshots only when you no longer need them, because they can be large.
chrome-devtools stopWhat people use it for
- Finding why a long CLI session keeps increasing heap size in the Qwen Code repository
- Checking whether a dependency upgrade introduced objects that are never released
- Confirming that a fix stops a class count from growing across repeated snapshots
Frequently asked questions
How do I install the memory-leak-debug skill?
Download the skill ZIP from this page and unzip it into ~/.claude/skills/ or a project's .claude/skills/ folder. In the Claude apps, you can instead upload the ZIP under Settings, Capabilities, Skills.
What do I need to run the memory-leak-debug skill?
You need Node.js 22 or newer, the chrome-devtools CLI from the chrome-devtools-mcp npm package, and tmux. The skill also references the tmux-real-user-testing helper skill from the same repository, which the provided files do not include.
Is the memory-leak-debug skill free and what is its licence?
The source lists the licence as Apache-2.0 and does not list a price for the skill. The skill is part of the QwenLM/qwen-code repository.
Can I use this skill to debug memory leaks in my own Node.js app?
The source says the paths, commands and worked example are specific to the Qwen Code repository. The general heap snapshot technique could be adapted with effort, but the skill is not designed for unrelated apps.
Why does the skill need network access and run scripts?
The source says the skill runs scripts and uses the network. The network use is the optional npm install of chrome-devtools-mcp, which the agent offers only after you confirm. Review the scripts, such as find-leaf-node.sh, before running them.
Where are the heap snapshot files saved?
The skill says snapshots are written to the CLI's working directory with names like Heap.timestamp.pid.seq.heapsnapshot. Delete them when you no longer need them, since they can be large.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Use this skill if you contribute to the Qwen Code CLI and need a repeatable heap-snapshot workflow to find growing memory use. Pick something else if you only use Qwen Code, or if you want to debug an unrelated Node.js app, since the paths and worked example are specific to this repository.
Download the skill