Repository navigation
fix: memory leak in word highlighter - #346673
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 are reported for the word-highlighter decoration cleanup change.
No open issues 🎉
What changed in this PR
Fixes a word-highlighter memory leak by cleaning up stored decoration IDs for the original model when an editor detaches or replaces it.
Changes:
- Removes stale IDs unless another editor with a highlighter still displays the resource.
- Adds regression tests for model detachment, replacement, disposal, and shared-editor cleanup.
| File | Description |
|---|---|
src/vs/editor/contrib/wordHighlighter/test/browser/wordHighlighter.test.ts |
Adds lifecycle and shared-model regression tests. |
src/vs/editor/contrib/wordHighlighter/browser/wordHighlighter.ts |
Cleans up the original model’s stored decoration IDs while preserving shared ownership. |
Review effort: Balanced
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new notebook-cell tests leave the static WordHighlighter.query uncleared, making the disabled-highlighting test order-dependent because subsequent highlighters can start provider requests during construction.
1 open issue
Review effort: Max
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 11:40
Dmitriy Vasyura (dmitrivMS)
approved these changes
Nov 9, 2026
Dirk Bäumer (dbaeumer)
approved these changes
Nov 9, 2026
Aiday Marlen Kyzy (aiday-mar)
approved these changes
Nov 9, 2026
Dmitriy Vasyura (dmitrivMS)
merged commit Nov 9, 2026
4452c9b
into
microsoft:main
93 of 95 checks passed
Simon Siefke (SimonSiefke)
deleted the
fix/memory-leak-word-highlight-ids
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
The word highlighter stores decoration IDs in a static resource map. When an editor detaches or replaces its model, cleanup uses the editor’s current model and leaves the old resource’s IDs in that map.
Change
Use the highlighter’s original model to remove stale IDs when the editor changes models, and preserve them while another editor still displays that resource.
Before
When opening and closing JSON documents 17 times, stale highlight entries grow from 2 to 18, adding 256 bytes of decoration-ID strings. Total string growth is 27,472 bytes and 636 strings.
After
Stale highlight entries remain at zero. Total string growth is 27,100 bytes and 618 strings; other allocations remain, and only the 256-byte decoration-ID saving is attributed to this fix.
Test Video
word-highlight-ids-native.webm
AI disclosure: Model: GPT 6.1 Sol. Worktime: 13 min