Repository navigation
fix: memory leak in semantic tokens - #336024
Merged
Dmitriy Vasyura (dmitrivMS) merged 3 commits intoSep 28, 2026
Merged
Dmitriy Vasyura (dmitrivMS) merged 3 commits into
Dmitriy Vasyura (dmitrivMS) merged 3 commits into
Conversation
Martin Aeschlimann (aeschli)
previously approved these changes
Sep 17, 2026
Paul (pwang347)
previously approved these changes
Sep 17, 2026
roblourens
previously approved these changes
Sep 17, 2026
Vritant Bhardwaj (vritant24)
previously approved these changes
Sep 17, 2026
Dmitriy Vasyura (dmitrivMS)
requested changes
Sep 18, 2026
Dmitriy Vasyura (dmitrivMS)
left a comment
Collaborator
There was a problem hiding this comment.
See AI Review comment
Simon Siefke (SimonSiefke)
dismissed stale reviews from Vritant Bhardwaj (vritant24), roblourens, Paul (pwang347), and Martin Aeschlimann (aeschli)
via
September 27, 2026 18:26
833934f
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The cancellation races are handled at both RPC boundaries and covered by focused tests.
Review effort: Balanced
Findings: None
What changed in this PR
Prevents canceled semantic-token requests from retaining late extension results in the adapter cache.
Changes:
- Stops conversion and caching after extension-host cancellation.
- Releases results canceled during RPC transit.
- Adds coverage for full tokens, edits, cache reuse, and RPC races.
| File | Description |
|---|---|
extHostLanguageFeatures.ts |
Skips caching canceled results. |
mainThreadLanguageFeatures.ts |
Releases late canceled results. |
extHostSemanticTokens.test.ts |
Tests cancellation and cache cleanup. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Dmitriy Vasyura (dmitrivMS)
approved these changes
Sep 28, 2026
Dmitriy Vasyura (dmitrivMS)
enabled auto-merge (squash)
September 28, 2026 04:17
Collaborator
|
Simon Siefke (@SimonSiefke) Thank you! |
Ladislau Szomoru (lszomoru)
approved these changes
Sep 28, 2026
Martin Aeschlimann (aeschli)
approved these changes
Sep 28, 2026
Simon Siefke (SimonSiefke)
deleted the
fix/memory-leak-extHostSemanticTokens-cancellation
branch
September 29, 2026 11:15
Abdon Morales (abdonmorales)
pushed a commit
to abdonmorales/vscode-utcs
that referenced
this pull request
Oct 1, 2026
* Fix semantic token cache leak after cancellation * Fix semantic token cleanup when cancellation is in transit (cherry picked from commit 0d3c47e)
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
When a semantic-token request is canceled before an extension finishes, the adapter still saves the late token data in its result cache. The canceled request cannot release that entry.
Change
Check cancellation after the provider finishes, before converting or caching its token data.
Before
When requesting and canceling semantic tokens 37 times, the adapter keeps 37 old buffers totaling 740,000 bytes. Total ArrayBuffer memory grows by 742,245 bytes:
After
No more canceled token buffers remain in the adapter cache. The same test avoids the 740,000-byte leak; unrelated growth of 2,245 bytes and two backing stores remains:
Test Video
semantic-desktop-video.webm