Repository navigation
fix: memory leak in untitled editor resolution - #346674
Merged
Dmitriy Vasyura (dmitrivMS) merged 5 commits intoNov 9, 2026
Merged
Dmitriy Vasyura (dmitrivMS) merged 5 commits into
Dmitriy Vasyura (dmitrivMS) merged 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the changes preventing orphan text models when an untitled editor is disposed during asynchronous resolution.
No open issues 🎉
What changed in this PR
Prevents orphan text models when an untitled editor is disposed before or during asynchronous resolution.
Changes:
- Adds disposal checks before resolution and after content decoding, before creating the text model.
- Adds regression tests for disposal before resolution, during backup resolution, and during initial-content decoding.
| File | Description |
|---|---|
src/vs/workbench/services/untitled/test/browser/untitledTextEditor.test.ts |
Adds disposal-race regression tests and restores Sinon stubs during teardown. |
src/vs/workbench/services/untitled/common/untitledTextEditorModel.ts |
Guards resolution against creating text models after disposal. |
Review effort: Balanced
Dmitriy Vasyura (dmitrivMS)
requested changes
Nov 6, 2026
Dmitriy Vasyura (dmitrivMS)
left a comment
Collaborator
There was a problem hiding this comment.
Please consider CCR feedback.
Contributor
Author
|
Added some minor test changes to address Copilot feedback! |
Collaborator
|
Simon Siefke (@SimonSiefke) Thank you! |
Dmitriy Vasyura (dmitrivMS)
enabled auto-merge (squash)
November 9, 2026 10:07
Dmitriy Vasyura (dmitrivMS)
approved these changes
Nov 9, 2026
Alex Ross (alexr00)
approved these changes
Nov 9, 2026
Ladislau Szomoru (lszomoru)
approved these changes
Nov 9, 2026
auto-merge was automatically disabled
November 9, 2026 17:02
Pull request was closed
Dmitriy Vasyura (dmitrivMS)
enabled auto-merge (squash)
November 9, 2026 17:21
Dmitriy Vasyura (dmitrivMS)
merged commit Nov 9, 2026
bc92219
into
microsoft:main
60 of 78 checks passed
Simon Siefke (SimonSiefke)
deleted the
fix/memory-leak-untitled-resolve
branch
November 11, 2026 10:35
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
An untitled editor can be disposed while its initial contents or backup are being decoded. Resolution then creates a text model after disposal, leaving that model registered without its editor.
Change
Check disposal before resolution and again after decoding, before creating the text model.
Before
When starting resolution and disposing untitled editors 17 times, 17 additional orphan text models remain registered. Total string growth is 52,492 bytes and 2,359 strings.
After
No orphan text models remain. Total string growth is 484 bytes and 13 strings over the same 17 cycles.
Test Video
untitled-resolve-native.webm
AI disclosure: Model: GPT 6.1 Sol. Worktime: 18 min