memory-leak-audit

Audit TypeScript code for memory leaks and disposable lifecycle issues.

Updated Aug 30, 2026
One-click install
npx skills add https://github.com/Tyrizx/Tyrizx --skill memory-leak-audit-tyrizx
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: memory-leak-audit
Source: https://github.com/Tyrizx/Tyrizx/tree/main/.github/skills/memory-leak-audit
Command: npx skills add https://github.com/Tyrizx/Tyrizx --skill memory-leak-audit-tyrizx

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Event listeners, DOM handlers, and disposables that are never released cause listener counts and heap usage to grow over time, producing hard-to-diagnose memory leaks in long-running editor sessions. ## Core Features & Use Cases - Six-Step Audit Checklist: Covers DOM event listeners, one-time events, repeated method calls, model-tied DisposableStores, resource pools, and test validation. - Pattern Library with Anti-Patterns: Shows correct usage of addDisposableListener, Event.once, MutableDisposable, DisposableStore, and onWillDispose with validated PR references. - Verification Guidance: Explains how to confirm fixes via listener counts, ensureNoDisposablesAreLeakedInTestSuite, and the chat memory leak checker. - Use Case: When a terminal find widget leaks one listener per search, apply the MutableDisposable pattern from Step 3 to cap registrations at one active listener. ## Quick Start Review this file for memory leaks using the memory leak audit checklist and report any disposable pattern violations.

Frequently Asked Questions about memory-leak-audit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix memory leaks from event listeners in TypeScript?▼

Replace raw addEventListener or property handlers like .onclick with addDisposableListener, and register the result via this._register so it is disposed with the class. For one-time events, wrap the event with Event.once so the listener auto-removes after firing.

What is the difference between MutableDisposable and DisposableStore?▼

MutableDisposable holds at most one disposable, replacing the previous value on each assignment, which suits methods called repeatedly. DisposableStore collects many disposables and releases them all at once, which suits model-tied or item-scoped lifetimes.

Why does registering listeners in a repeatedly called method cause leaks?▼

Each call to this._register inside a non-constructor method adds another listener to the class store, so registrations grow linearly with invocations. Use a MutableDisposable field or return an IDisposable to the caller instead.

How do I verify a memory leak fix in tests?▼

Call ensureNoDisposablesAreLeakedInTestSuite at the top of the test suite so leaked disposables fail the tests automatically. Also compare listener counts before and after repeated operations to confirm counts stabilize.

When should I use Event.once instead of a regular event subscription?▼

Use Event.once for lifecycle events that should fire only once, such as disposal, close, or first-change notifications. A regular subscription stays registered after the first fire, leaking the listener for the emitter's lifetime.