fix: memory leak in debug adapter descriptor factory by SimonSiefke · Pull Request #334103 · microsoft/vscode · GitHub
Skip to content

fix: memory leak in debug adapter descriptor factory - #334103

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

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

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Registering a debug adapter descriptor factory adds its registration disposable to the MainThreadDebugService lifetime store. Unregistering the factory removes it from the adapter manager but leaves that disposable in the store, so the factory callback remains until the extension host bridge is disposed.

Change

Store debug adapter descriptor factory registrations by handle and dispose each registration when its factory unregisters.

Before

When registering and disposing a debug adapter descriptor factory 37 times, the descriptor callback and registration disposal closure each grow by 37:

before

After

No debug adapter descriptor callback or registration disposal closure leak is detected.

Test Video

test-video.webm

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

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 lifecycle fix correctly removes retained callbacks and includes suitable regression coverage.

Pull request overview

Fixes debug adapter descriptor factory registration leaks in the extension-host bridge.

Changes:

  • Tracks registrations by handle using DisposableMap.
  • Disposes registrations immediately when unregistered.
  • Adds regression coverage for disposal.
File summaries
File Description
src/vs/workbench/api/browser/mainThreadDebugService.ts Manages factory registration lifetimes per handle.
src/vs/workbench/api/test/browser/mainThreadDebugService.test.ts Verifies unregistering disposes the registration.
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

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 3468b27 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-debugAdapterDescriptorFactory 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.

6 participants