Skip to content

fix: memory leak in extension host hierarchy - #336023

Merged
Dmitriy Vasyura (dmitrivMS) merged 1 commit into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-extHostHierarchy-cancellation
Sep 18, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 1 commit into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-extHostHierarchy-cancellation

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Closing Call Hierarchy or Type Hierarchy before a provider responds can leave its returned items in the extension host's session cache. The canceled request never delivers the session ID needed to release those items.

Change

Check cancellation after the provider responds, before creating a hierarchy session.

Before

Opening and canceling both hierarchies 37 times leaves 37 extra call hierarchy items and 37 extra type hierarchy items:

before

After

No more growth is detected in the same 37-cycle measurement.

Test Video

video.webm

Copilot AI balanced review requested due to automatic review settings September 13, 2026 09:10

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 cancellation guards directly prevent orphaned cache entries and are covered for both hierarchy implementations.

Pull request overview

Prevents canceled hierarchy requests from leaking provider-returned items in extension-host caches.

Changes:

  • Skip call/type hierarchy session creation after cancellation.
  • Add regression tests for canceled and active session lifecycles.
File summaries
File Description
src/vs/workbench/api/common/extHostLanguageFeatures.ts Guards session caching after provider completion.
src/vs/workbench/api/test/browser/extHostHierarchy.test.ts Tests cancellation cleanup and explicit release behavior.
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

Simon Siefke (@SimonSiefke) Thank you!

@dmitrivMS Dmitriy Vasyura (dmitrivMS) added this to the 1.139.0 milestone Sep 18, 2026
@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 1ead63e into microsoft:main Sep 18, 2026
33 checks passed
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-extHostHierarchy-cancellation branch September 20, 2026 07:39
Abdon Morales (abdonmorales) pushed a commit to abdonmorales/vscode-utcs that referenced this pull request Sep 23, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Nov 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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