
Memory Leak Audit
This is a checklist-driven audit for catching disposable and event listener leaks in VS Code extension code. You'd reach for it when reviewing code that registers DOM handlers, fixing reported leaks where listener counts grow unbounded, or working with lifecycle callbacks. It walks through six patterns in order: using addDisposableListener for DOM events, Event.once for one-time fires, MutableDisposable for methods called repeatedly, model-tied DisposableStores, resource pool disposal scoping, and test validation. Each rule is validated against actual VS Code PRs where these patterns prevented or fixed real leaks. The practical bit is the sequential checklist format, since missing even one pattern can leak thousands of objects over time.
- skills.sh installs
- 3.2K
- GitHub stars
- 195.3K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add microsoft/vscode --skill memory-leak-audit --agent claude-codeInstalls into .claude/skills of the current project.
Files
Memory Leak Audit
The #1 bug category in VS Code. This skill encodes the patterns that prevent and fix leaks.
When to Use
- Reviewing code that registers event listeners or DOM handlers
- Fixing reported memory leaks (listener counts growing over time)
- Creating objects in methods that are called repeatedly
- Working with model lifecycle events (onWillDispose, onDidClose)
- Adding event subscriptions in constructors or setup methods
Audit Checklist
Work through each check in order. A single missed pattern can cause thousands of leaked objects.
Step 1: DOM Event Listeners
Rule: Never use raw .onload, .onclick, or addEventListener() directly. Always use addDisposableListener().
// BAD — leaks a listener every call
this.iconElement.onload = () => { ... };
// GOOD — tracked and disposable
this._register(addDisposableListener(this.iconElement, 'load', () => { ... }));
Validated by: PR #280566 — Extension icon widget leaked 185 listeners after 37 toggles.
Step 2: One-Time Events
Rule: Use Event.once() for events that should only fire once (lifecycle events, close events, first-change events).
Sponsors
Details
- Repository
- github.com/microsoft/vscode
- Categories
- Frontend Development, Debugging
- First seen
- Apr 16, 2026