Skip to content

fix: memory leak in workspace symbols - #336029

Merged
Dmitriy Vasyura (dmitrivMS) merged 2 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-extHostWorkspaceSymbols-cancellation
Sep 18, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 2 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-extHostWorkspaceSymbols-cancellation

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

When a workspace-symbol request is canceled before an extension finishes, the adapter still saves the late symbols in its result cache. The canceled request cannot release that cache entry.

Change

Check the cancellation token after the provider finishes, before caching or converting its symbols.

Before

When requesting and canceling workspace symbols 37 times, 37 old symbols and their locations remain in the cache:

symbols-before

After

No more workspace-symbol cache growth is detected in the same 37-cycle test.

Test Video

symbols-desktop-video.webm

Copilot AI balanced review requested due to automatic review settings September 13, 2026 09:28
@SimonSiefke Simon Siefke (SimonSiefke) changed the title ### Details When a workspace-symbol request is canceled before an extension finishes, the adapter still saves the late symbols in its result cache. The canceled request cannot release that cache entry. ### Change Check the cancellation token after the provider finishes, before caching or converting its symbols. ### Before When requesting and canceling workspace symbols 37 times, 37 old symbols and their locations remain in the cache: <img width="1400" height="40" alt="symbols-before" src="https://github.com/user-attachments/assets/c810a787-4ff7-4eef-a77d-c8186186e5cb" /> ### After No more workspace-symbol cache growth is detected in the same 37-cycle test. ### Test Video https://github.com/user-attachments/assets/55122668-1e6f-499e-ab50-839b42b3f1df fix: memory leak in workspace symbols Sep 13, 2026

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Prevents workspace-symbol requests that get canceled from caching and later resolving “late” results, which previously caused cache growth/leaks.

Changes:

  • Add a new browser test suite validating cancellation doesn’t populate/resolve cached workspace symbols.
  • Add a cancellation check after provider completion to avoid caching/conversion for canceled requests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/vs/workbench/api/test/browser/extHostWorkspaceSymbols.test.ts Adds regression tests covering symbol caching behavior under cancellation and after cache release.
src/vs/workbench/api/common/extHostLanguageFeatures.ts Prevents caching/returning workspace symbols when the request token is canceled after provider returns.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/vs/workbench/api/test/browser/extHostWorkspaceSymbols.test.ts
Comment thread src/vs/workbench/api/common/extHostLanguageFeatures.ts
@dmitrivMS

Copy link
Copy Markdown
Collaborator

Simon Siefke (@SimonSiefke) Thank you!

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit ece3c56 into microsoft:main Sep 18, 2026
33 checks passed
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-extHostWorkspaceSymbols-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
* Fix workspace symbol cache leak after cancellation

* docs: explain workspace symbol cancellation cleanup

(cherry picked from commit ece3c56)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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