memory-leak-audit

Audit code for memory leaks and disposable issues in event listeners and lifecycle callbacks.

189k|41.5k|Updated Sep 3, 2015
One-click install
npx skills add https://github.com/microsoft/vscode --skill memory-leak-audit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: memory-leak-audit
Source: https://github.com/microsoft/vscode/tree/main/.github/skills/memory-leak-audit
Command: npx skills add https://github.com/microsoft/vscode --skill memory-leak-audit

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the critical issue of memory leaks in code, which can degrade application performance and stability over time. It provides a systematic approach to identify and rectify common causes of leaks.

Core Features & Use Cases

  • Event Listener Auditing: Ensures proper handling of DOM and custom event listeners to prevent them from accumulating.
  • Lifecycle Management: Guides the correct disposal of resources tied to object lifecycles.
  • Use Case: When reviewing code that handles user interactions or background processes, use this Skill to ensure that no event listeners or subscriptions are left active after they are no longer needed, preventing gradual memory consumption.

Quick Start

Audit the current code for potential memory leaks by following the checklist in the SKILL.md file.

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 caused by event listeners in JavaScript applications?

To fix JavaScript memory leaks from event listeners, audit code to ensure proper disposal of DOM and custom handlers. Enforce patterns like addDisposableListener and DisposableStore to prevent listeners from accumulating and consuming memory over time.

What is the best way to manage disposable resources and prevent leaks in TypeScript?

The best way to manage disposable resources is to enforce disposal patterns tied to object lifecycles. Implement MutableDisposable and Event.once patterns to systematically release subscriptions and background processes when they are no longer needed.

How do I audit my codebase for memory leaks and disposable issues?

You audit your codebase for memory leaks by applying a checklist focusing on event listeners, DOM handlers, and lifecycle callbacks. This verifies that subscriptions and resources are properly disposed of using patterns like DisposableStore.

Why does my application gradually consume more memory during user interactions?

Your application gradually consumes memory during user interactions because event listeners and DOM handlers accumulate without proper disposal. Auditing the code for lifecycle management issues identifies and rectifies these active resource leaks.

When do I need to use DisposableStore or MutableDisposable patterns?

You need to use DisposableStore or MutableDisposable patterns when managing resources tied to object lifecycles, ensuring that event listeners and subscriptions are automatically cleaned up to prevent gradual memory consumption and stability degradation.