memory-leak-audit

Solid

Audit code for memory leaks and disposable issues. Use when reviewing event listeners, DOM handlers, lifecycle callbacks, or fixing leak reports. Covers addDisposableListener, Event.once, MutableDisposable, DisposableStore, and onWillDispose patterns.

Code & Development 25 stars 0 forks Updated 5 days ago MIT

Install

View on GitHub

Quality Score: 82/100

Stars 20%
47
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 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()`. ```typescript // 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). ```typescript // BAD — listener stays registered forever after first fire model.onDidDispose(() => store.dispose()); // GOOD — auto-removes after first invocation Event.once(model.onDidDispose)(() => store.dispose()); ``` **Validated by**: PRs #285657, #285661 — Terminal lifecycle hacks replaced with `Event.once()`. ### S...

Details

Author
chapmanjw
Repository
chapmanjw/clawdius
Created
2 months ago
Last Updated
5 days ago
Language
TypeScript
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category