Skip to content

fix: memory leak in search progress emitter - #346126

Merged
Dmitriy Vasyura (dmitrivMS) merged 2 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-search-progress-emitter
Nov 5, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 2 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-search-progress-emitter

Conversation

@SimonSiefke

@SimonSiefke Simon Siefke (SimonSiefke) commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Details

Each search registers a progress emitter in SearchModelImpl’s disposable store. The telemetry handler disposes its listener, but leaves the emitter and its leak-warning string in the store until the model is disposed.

Change

Remove and dispose the emitter after the first progress event or search completion.

Before

Opening and closing a search editor 37 times adds 37 emitters and event callbacks. These allocation counts include the core files normally excluded by the default measure.

Before

After

The progress emitters and event callbacks no longer accumulate after 37 and 111 cycles. The separate decoration cache growth remains visible.

After

Test Video

search-editor-lifecycle-churn.webm

AI disclosure: Model: gpt-6.1-sol. Worktime: 22 min

Copilot AI balanced review requested due to automatic review settings November 4, 2026 21:10

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.

🟢 Approval recommended

No active review issues remain for the change addressing search progress-emitter retention.

No open issues 🎉

What changed in this PR

Fixes a memory leak in the search model by releasing each search’s progress emitter instead of retaining it until the model is disposed.

Changes:

  • Removes and disposes the emitter after the first progress event or search completion.
  • Adds regression tests for both cleanup paths, including subsequent progress events.
File Description
src/​vs/​workbench/​contrib/​search/​test/​browser/​searchModel.test.ts Tests emitter cleanup after progress and completion.
src/​vs/​workbench/​contrib/​search/​browser/​searchTreeModel/​searchModel.ts Deletes the completed progress emitter from the model’s disposable store.

Review effort: Balanced

@dmitrivMS

Copy link
Copy Markdown
Collaborator

Simon Siefke (@SimonSiefke) Thank you!

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.

🟢 Approval recommended

No active review issues block the search-model progress-emitter cleanup.

No open issues 🎉

Review effort: Max

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 0ffea05 into microsoft:main Nov 5, 2026
59 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 5, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-search-progress-emitter branch November 5, 2026 11:28
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 search Search widget and operation issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants