Skip to content

fix: memory leak in terminal find widget - #346139

Merged
Dmitriy Vasyura (dmitrivMS) merged 4 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-terminal-find-widget
Nov 5, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 4 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-terminal-find-widget

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

The terminal find contribution subscribes to focus and blur when it creates its widget. Those subscription handles are never disposed with the contribution, so development disposable tracking reports leaked handles and records their creation stacks.

Change

Register both focus subscriptions with the terminal contribution so they are disposed before the find widget.

Before

With development disposable tracking enabled, opening and closing two terminals and opening find 37 times produces two growing terminal find creation stacks. Each contains 37 complete stack strings and 2,146 component string objects.

Before

After

No terminal find creation-stack group grows in the matched run. Aggregate growth falls from 4,743 to 380 strings and from 140,144 to 14,748 shallow bytes. The independent terminal decoration cache growth and other string groups remain visible.

After

Test Video

test-video.webm

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

Copilot AI balanced review requested due to automatic review settings November 4, 2026 22:33
@vs-code-engineering

vs-code-engineering Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Anthony Kim (@anthonykim1)

Matched files:

  • src/vs/workbench/contrib/terminalContrib/find/browser/terminal.find.contribution.ts

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 were identified for the terminal find widget subscription cleanup change.

No open issues 🎉

What changed in this PR

Fixes a terminal find widget memory leak by tying its focus and blur subscriptions to the terminal contribution’s disposal lifecycle.

Changes:

  • Registers both subscriptions for disposal with the contribution.
  • Exports the contribution class for regression tests covering subscription cleanup and disposal without creating an unused widget.
File Description
src/​vs/​workbench/​contrib/​terminalContrib/​find/​test/​browser/​terminalFindContribution.test.ts Adds regression tests for subscription cleanup and lazy widget creation.
src/​vs/​workbench/​contrib/​terminalContrib/​find/​browser/​terminal.find.contribution.ts Registers focus subscriptions for disposal and exports the class for testing.

Review effort: Balanced

@dmitrivMS Dmitriy Vasyura (dmitrivMS) added freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues terminal General terminal issues that don't fall under another label labels Nov 4, 2026
@dmitrivMS

Copy link
Copy Markdown
Collaborator

Simon Siefke (@SimonSiefke) Thank you!

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 14a0f1a 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-terminal-find-widget 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 terminal General terminal issues that don't fall under another label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants