Repository navigation
fix: memory leak in extension host language model providers - #340579
Merged
Dmitriy Vasyura (dmitrivMS) merged 3 commits intoOct 9, 2026
Merged
Dmitriy Vasyura (dmitrivMS) merged 3 commits into
Dmitriy Vasyura (dmitrivMS) merged 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The identity guard correctly prevents stale cache writes and is covered by focused lifecycle tests.
0 open findings
What changed in this PR
Prevents stale model discovery results from repopulating the extension host cache after a provider is disposed or replaced.
Changes:
- Verifies provider registration identity after asynchronous discovery.
- Adds disposal, replacement, cache-clearing, and regression tests.
| File | Description |
|---|---|
src/vs/workbench/api/common/extHostLanguageModels.ts |
Discards results from stale provider registrations. |
src/vs/workbench/api/test/common/extHostLanguageModels.test.ts |
Tests provider disposal and replacement behavior. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Collaborator
|
Simon Siefke (@SimonSiefke) Thank you! |
Dmitriy Vasyura (dmitrivMS)
enabled auto-merge (squash)
October 9, 2026 07:51
Dmitriy Vasyura (dmitrivMS)
approved these changes
Oct 9, 2026
Martin Aeschlimann (aeschli)
approved these changes
Oct 9, 2026
Nick Trogh (ntrogh)
approved these changes
Oct 9, 2026
Dmitriy Vasyura (dmitrivMS)
merged commit Oct 9, 2026
5042306
into
microsoft:main
55 of 56 checks passed
Simon Siefke (SimonSiefke)
deleted the
fix/memory-leak-languageModelProviderDisposal
branch
October 13, 2026 09:40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Details
A language model provider can be disposed while its model discovery is pending. The completed discovery still writes the old catalog into ExtHostLanguageModels._localModels, even after a replacement provider has registered.
Change
Check the original provider registration after discovery completes and discard results from a disposed or replaced registration.
Before
When starting discovery and disposing a provider before its 37-model catalog returns over 37 cycles, the extension host keeps 37 old model objects. Named-function-count3 on the matched heap captures shows
DisposedDiscoveryModelInformationgrowing by 37 (38 total).After
No more leak detected.
Test Video
test-video.webm
AI disclosure: Model: GPT-6.1-Sol. Worktime: 11 min