Skip to content

fix: memory leak in search result folder matches - #331012

Merged
Dmitriy Vasyura (dmitrivMS) merged 2 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-search-result-folder-matches
Aug 16, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 2 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-search-result-folder-matches

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Each search query registered its transient workspace-root and “Other files” folder matches in the search heading's lifetime disposable store. Disposing those matches did not remove them from the store, so previous search results stayed reachable.

Change

Folder matches now use the existing query-result disposal lifecycle, and their change listener is released by a one-shot disposal listener instead of the search heading's lifetime store.

Before

When opening and closing a search editor 37 times, search result folder matches, callbacks, and their resource map grow with each run:

before

After

No more search result folder-match leak is detected. The remaining rows belong to the independent search editor input and model leak.

after

Test Video

test-video.webm

Copilot AI balanced review requested due to automatic review settings August 15, 2026 11:22

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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR adjusts lifecycle/disposal handling when creating folder match nodes for the text search tree.

Changes:

  • Stops registering newly created ISearchTreeFolderMatch instances with the heading’s disposable tracking.
  • Switches the onDispose handler wiring to Event.once(...) instead of registering a disposable callback.
  • Stops registering FolderMatchNoRootImpl instances with the heading’s disposable tracking.

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

@javi0guerrero4-cloud

Copy link
Copy Markdown

Let's go

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 31b0155 into microsoft:main Aug 16, 2026
27 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.134.0 milestone Aug 16, 2026

@Nigerian455 Nigerian455 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5743026771

@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-search-result-folder-matches branch September 1, 2026 14:33
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Sep 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants