# memory-leak-audit

> Claude/Codex skill by [@microsoft](https://omgskills.com/library/microsoft/index.md) · 193k stars · Updated 2026-09-26

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.

Tags: editor, electron, microsoft, typescript, visual-studio-code

## Install

```sh
git clone https://github.com/microsoft/vscode /tmp/vscode && ln -s /tmp/vscode/.github/skills/memory-leak-audit ~/.claude/skills/memory-leak-audit
```

## From README

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 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(). 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). Validated by: PRs \#285657, \#285661 — Terminal lifecycle hacks replaced with Event.once().

## Links

- HTML page: https://omgskills.com/skills/microsoft/vscode/memory-leak-audit/
- GitHub: https://github.com/microsoft/vscode
- Author: [@microsoft](https://omgskills.com/library/microsoft/index.md)

## More from this repo

- [accessibility](https://omgskills.com/skills/microsoft/vscode/accessibility/index.md) — Primary accessibility skill for VS Code.
   - [@microsoft](https://omgskills.com/library/microsoft/index.md) · 193k stars
- [act-on-feedback](https://omgskills.com/skills/microsoft/vscode/act-on-feedback/index.md) — Act on user feedback attached to the current session.
   - [@microsoft](https://omgskills.com/library/microsoft/index.md) · 193k stars
- [agent-customization](https://omgskills.com/skills/microsoft/vscode/agent-customization/index.md) — \*\*WORKFLOW SKILL\*\* — Create, update, review, fix, or debug VS Code agent customization files (.instructions.md,...
   - [@microsoft](https://omgskills.com/library/microsoft/index.md) · 193k stars
