fix: memory leak in MainThreadDebugService by SimonSiefke · Pull Request #334102 · microsoft/vscode · GitHub
Skip to content

fix: memory leak in MainThreadDebugService - #334102

Merged
Dmitriy Vasyura (dmitrivMS) merged 3 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-mainThreadDebugService
Oct 5, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 3 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-mainThreadDebugService

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Registering a debug configuration provider adds its registration disposable to the MainThreadDebugService lifetime store. Unregistering the provider removes it from the debug configuration manager but leaves that disposable in the store, so the provider callbacks remain until the extension host bridge is disposed.

Change

Store debug configuration registrations by handle and dispose each registration when its provider unregisters.

Before

When registering and disposing a debug configuration provider 37 times, the provider callback and registration disposal closure each grow by 37:

debug-provider-before

After

No more debug configuration provider callback or disposal closure leak is detected.

Test Video

debug-provider-test-video.webm

Copilot AI balanced review requested due to automatic review settings September 2, 2026 20:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fix follows established disposable lifecycle patterns and includes appropriate regression coverage.

Pull request overview

Fixes a MainThreadDebugService leak by disposing provider registrations when unregistered.

Changes:

  • Tracks registrations in a handle-keyed DisposableMap.
  • Adds regression coverage for registration disposal.
File summaries
File Description
mainThreadDebugService.ts Disposes provider registrations by handle.
mainThreadDebugService.test.ts Verifies disposal during unregistration.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@dmitrivMS

Copy link
Copy Markdown
Collaborator

Preserve configuration-provider and descriptor-factory registration cleanup and both regression tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 3e28fe0 into microsoft:main Oct 5, 2026
35 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.142.0 milestone Oct 5, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-mainThreadDebugService branch October 5, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

debug Debug viewlet, configurations, breakpoints, adapter issues freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants