Skip to content

fix: memory leak in extension host comments - #334095

Merged
Alex Ross (alexr00) merged 2 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-extHostComments
Sep 3, 2026
Merged

Alex Ross (alexr00) merged 2 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-extHostComments

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

When an extension creates a comment controller, the extension host stores the controller by its handle. Disposing the controller unregisters it from the main thread, but does not remove it from the extension host map.

Change

Remove disposed comment controllers from the extension host map and remove the unused per-extension controller list.

Before

When a comment controller is created and disposed 37 times, ExtHostCommentController and its API callbacks grow by 37:

before

After

No more extension host comment controller leak is detected.

Test Video

test-video.webm

Copilot AI balanced review requested due to automatic review settings September 2, 2026 19:26

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 cleanup is covered by a regression test, with no unresolved issues.

Pull request overview

Fixes a memory leak by removing disposed comment controllers from extension-host bookkeeping.

Changes:

  • Removes disposed controllers from the handle map.
  • Deletes unused per-extension controller storage.
  • Adds regression coverage for disposal cleanup.
File summaries
File Description
src/vs/workbench/api/test/common/extHostComments.test.ts Verifies disposed controllers cannot receive thread requests.
src/vs/workbench/api/common/extHostComments.ts Cleans up controller bookkeeping on disposal.
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.

@alexr00 Alex Ross (alexr00) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for the PR!

@alexr00
Alex Ross (alexr00) enabled auto-merge (squash) September 3, 2026 09:12
@alexr00 Alex Ross (alexr00) added this to the 1.137.0 milestone Sep 3, 2026
@alexr00
Alex Ross (alexr00) merged commit 6f7c195 into microsoft:main Sep 3, 2026
30 checks passed
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-extHostComments branch September 20, 2026 07:39
Abdon Morales (abdonmorales) pushed a commit to abdonmorales/vscode-utcs that referenced this pull request Sep 23, 2026
* fix: memory leak in extHostComments

* Attestation commit

---------

Co-authored-by: Alex Ross <[email protected]>
(cherry picked from commit 6f7c195)
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Oct 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants