Community코딩 & 개발github.com

마이크로소프트/메모리-누수-감사

코드에서 메모리 누수 및 해제 가능 문제를 감사합니다. 이벤트 리스너, DOM 핸들러, 생명주기 콜백을 검토하거나 누수 보고서를 수정할 때 사용하세요. addDisposableListener, Event.once, MutableDisposable, DisposableStore 및 onWillDispose 패턴을 다룹니다.

메모리-누수-감사란 무엇인가요?

이 기술은 Microsoft의 메모리 누수 감사 도구로, 코드에서 메모리 누수 및 해제 가능(disposable) 문제를 자동으로 찾아내고 수정을 제안합니다. 주로 VSCode와 같은 TypeScript/JavaScript 기반 프로젝트에서 사용되며, addDisposableListener, Event.once, MutableDisposable, DisposableStore, onWillDispose와 같은 일반적인 패턴을 분석합니다. 개발자가 이벤트 리스너, DOM 핸들러, 생명주기 콜백을 검토하거나 메모리 누수 보고서를 수정할 때 특히 유용합니다. 또한 사용자 정의 누수 규칙이나 감사 수준을 설정할 수 있어 팀의 코딩 표준에 맞게 조정할 수 있습니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/microsoft/vscode/tree/main/skills/memory-leak-audit

Installed? Explore more 코딩 & 개발 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

메모리-누수-감사은(는) 무엇을 하나요?

코드에서 메모리 누수 및 해제 가능 문제를 감사합니다. 이벤트 리스너, DOM 핸들러, 생명주기 콜백을 검토하거나 누수 보고서를 수정할 때 사용하세요. addDisposableListener, Event.once, MutableDisposable, DisposableStore 및 onWillDispose 패턴을 다룹니다.

개요

이 감사 도구는 일반적인 메모리 누수 패턴을 식별하고, 해제 가능한 리소스가 적절히 관리되도록 보장합니다. 특히 TypeScript/JavaScript 프로젝트에서 Disposable 패턴을 사용하는 경우에 적합합니다.

사용 방법

CLI

npx microsoft/memory-leak-audit --target ./src

프로그래밍 방식

const { audit } = require('microsoft/memory-leak-audit');

const results = audit({
  files: ['./src/**/*.ts'],
  rules: ['addDisposableListener', 'MutableDisposable']
});

console.log(results);

지원 패턴

패턴설명
addDisposableListener이벤트 리스너가 적절히 해제되었는지 확인
Event.once일회성 이벤트 리스너의 올바른 사용 확인
MutableDisposable변경 가능한 해제 가능 객체의 누수 방지
DisposableStore해제 가능 저장소가 적절히 관리되는지 확인
onWillDispose해제 전 콜백의 올바른 사용 확인

구성

.memory-leak-audit.json 파일을 만들어 규칙과 감사 수준을 사용자 정의할 수 있습니다:

{
  "rules": {
    "addDisposableListener": "error",
    "Event.once": "warning",
    "MutableDisposable": "error",
    "DisposableStore": "error",
    "onWillDispose": "warning"
  },
  "ignorePatterns": ["**/node_modules/**", "**/out/**"]
}

예제

잘못된 사용

// 누수 발생: 이벤트 리스너가 해제되지 않음
document.addEventListener('click', this.handleClick);

올바른 사용

// 해제 가능 리스너 사용
this._register(addDisposableListener(document, 'click', this.handleClick));

라이선스

MIT

Individual skills in this repo

This repo contains 10 individual skills — each has its own dedicated page.

microsoft/accessibility

Primary accessibility skill for VS Code. REQUIRED for new feature and contribution work, and also applies to updates of existing UI. Covers accessibility help dialogs, accessible views, verbosity settings, signals, ARIA announcements, keyboard navigation, and ARIA labels/roles.

microsoft/agent-sessions-layout

Agents workbench layout — covers the fixed layout structure, grid configuration, part visibility, editor modal, titlebar, sidebar footer, and implementation requirements. Use when implementing features or fixing issues in the Agents workbench layout.

microsoft/author-contributions

Identify all files a specific author contributed to on a branch vs its upstream, tracing code through renames. Use when asked who edited what, what code an author contributed, or to audit authorship before a merge. This skill should be run as a subagent — it performs many git operations and returns a concise table.

microsoft/azure-pipelines

Use when validating Azure DevOps pipeline changes for the VS Code build. Covers queueing builds, checking build status, viewing logs, and iterating on pipeline YAML changes without waiting for full CI runs.

microsoft/fix-errors

Guidelines for fixing unhandled errors from the VS Code error telemetry dashboard. Use when investigating error-telemetry issues with stack traces, error messages, and hit/user counts. Covers tracing data flow through call stacks, identifying producers of invalid data vs. consumers that crash, enriching error messages for telemetry diagnosis, and avoiding common anti-patterns like silently swallowing errors.

microsoft/hygiene

Use when making code changes to ensure they pass VS Code's hygiene checks. Covers the pre-commit hook, unicode restrictions, string quoting rules, copyright headers, indentation, formatting, ESLint, and stylelint. Run the hygiene check before declaring work complete.

microsoft/sessions

Agents window architecture — covers the agents-first app, layering, folder structure, chat widget, menus, contributions, entry points, and development guidelines. Use when implementing features or fixing issues in the Agents window.

microsoft/tool-rename-deprecation

Ensure renamed built-in tool references preserve backward compatibility. Use when renaming a toolReferenceName, tool set referenceName, or any tool identifier. Run on ANY change to tool registration code. Covers legacyToolReferenceFullNames for tools and legacyFullNames for tool sets.

microsoft/update-screenshots

Download screenshot baselines from the latest CI run and commit them. Use when asked to update, accept, or refresh component screenshot baselines from CI, or after the screenshot-test GitHub Action reports differences. This skill should be run as a subagent.

microsoft/validate-ui-scenario

Use when reproducing a UI bug or verifying a fix by driving a real VS Code window end to end and capturing evidence. Writes a scenario file, runs it against a dev build or installed Insiders, and produces a captioned video, per-step screenshots, a Playwright trace, and an HTML report to attach to an issue or pull request.

관련 스킬