Repository navigation
fix: memory leak in file search listeners - #345781
Merged
Dmitriy Vasyura (dmitrivMS) merged 2 commits intoNov 5, 2026
Merged
Dmitriy Vasyura (dmitrivMS) merged 2 commits into
Dmitriy Vasyura (dmitrivMS) merged 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the listener-cleanup change.
No open issues 🎉
What changed in this PR
This PR fixes listener retention in VS Code’s file search service by disposing subscriptions when search promises settle, preventing completed requests from accumulating callbacks.
Changes:
- Dispose cached-search progress and cancellation listeners on completion or failure.
- Dispose engine cancellation listeners when searches settle.
- Add regression tests for cached-search listener cleanup and cancellation after completion.
| File | Description |
|---|---|
src/vs/workbench/services/search/test/node/rawSearchServiceListeners.test.ts |
Adds listener-cleanup and post-completion cancellation tests. |
src/vs/workbench/services/search/node/rawSearchService.ts |
Disposes progress and cancellation subscriptions using promise finalizers. |
Review effort: Balanced
Dmitriy Vasyura (dmitrivMS)
approved these changes
Nov 4, 2026
Dmitriy Vasyura (dmitrivMS)
enabled auto-merge (squash)
November 4, 2026 22:48
Collaborator
|
Simon Siefke (@SimonSiefke) Thank you! |
Vijay Upadya (vijayupadya)
approved these changes
Nov 5, 2026
Vritant Bhardwaj (vritant24)
approved these changes
Nov 5, 2026
Simon Siefke (SimonSiefke)
deleted the
fix/memory-leak-search-listeners
branch
November 5, 2026 11:28
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
Each cached file search subscribes its progress callback to the cached row. Completed searches leave that callback subscribed, and cancellation listeners also stay registered after the search finishes. Reusing one cache keeps adding callbacks for completed requests.
Change
Dispose progress and cancellation subscriptions when each search promise settles.
Before
Alternating two file queries in the same Quick Open picker for 37 runs adds 74
fileProgressCallbackclosures and their result callbacks in the extension host:After
No more leak detected.
Test Video
search-listener-churn-quarter-speed.webm
AI disclosure: Model: unknown. Worktime: unknown