Skip to content

fix: memory leak in search editor - #331014

Open
Simon Siefke (SimonSiefke) wants to merge 2 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-search-editor
Open

fix: memory leak in search editor#331014
Simon Siefke (SimonSiefke) wants to merge 2 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-search-editor

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Search editor panes registered each input's configuration listener for the pane lifetime, while the model factory kept resolved models after their input was disposed. Closing and reopening search editors therefore retained the input, configuration, and results text model graph.

Change

Configuration listeners are now scoped to the active editor input, and disposing a SearchEditorInput removes its model factory entry.

Before

When opening and closing a search editor 37 times, the search editor input, configuration, and results text model graph grows with each run:

before

After

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

after

Test Video

test-video.webm

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

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 improves lifecycle management for Search Editor resources by ensuring per-input listeners and cached models are released when inputs are cleared or disposed.

Changes:

  • Add explicit disposal for SearchEditorModel instances so they can be removed from the shared factory cache.
  • Dispose the SearchEditorModel from SearchEditorInput.dispose() to avoid retaining cached models after an input is closed.
  • Track and clear per-input disposables in SearchEditor to prevent event listener leaks across input switches.

Reviewed changes

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

File Description
src/vs/workbench/contrib/searchEditor/browser/searchEditorModel.ts Adds dispose() to remove a model from the global factory cache.
src/vs/workbench/contrib/searchEditor/browser/searchEditorInput.ts Ensures the Search Editor model is disposed when the input is disposed.
src/vs/workbench/contrib/searchEditor/browser/searchEditor.ts Introduces inputDisposables to scope and clear disposables when inputs change/clear.

💡 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/contrib/searchEditor/browser/searchEditorModel.ts
Comment thread src/vs/workbench/contrib/searchEditor/browser/searchEditor.ts
Comment thread src/vs/workbench/contrib/searchEditor/browser/searchEditor.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants