Skip to content

fix: memory leak in multi diff editor tabs - #333186

Merged
Dmitriy Vasyura (dmitrivMS) merged 5 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-editorTabs-multiDiff
Sep 29, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 5 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-editorTabs-multiDiff

Conversation

@SimonSiefke

@SimonSiefke Simon Siefke (SimonSiefke) commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #228367

Details

Opening and closing the Source Control multi-diff editor 37 times retained 37 MultiDiffEditorInput instances, 37 view models and SCM sources, and 111 diff items. The shortest retaining path ended at MainThreadEditorTabs._multiDiffEditorInputListeners.

Change

Dispose the multi-diff resource listener using the original editor input stored in TabInfo when the tab closes. Add a browser regression assertion that the listener map returns to zero after the open/close event sequence.

Before

The multi-diff input graph grew once per iteration. The highlighted rows are fixed by this change; the unrelated DomListener row is intentionally excluded.

before

After

The multi-diff inputs, sources, view models, items, and tab listener callbacks no longer grow. A separate DomListener row remains at the unchanged baseline delta of 69 and is outside this focused fix.

after

Test Video

test-video.webm

Copilot AI balanced review requested due to automatic review settings August 28, 2026 15:04

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

Fixes a retained multi-diff resource listener when editor tabs close.

Changes:

  • Disposes listeners using the original EditorInput.
  • Adds regression assertions for listener cleanup.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
mainThreadEditorTabs.ts Corrects listener disposal on tab closure.
mainThreadEditorTabs.test.ts Verifies listener-map cleanup.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Note

This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.

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.

Copilot review overview

🟢 Approval recommended

The listener lifecycle fix correctly handles shared inputs and is covered by focused regression assertions.

Review effort: Balanced
Findings: None

Keep private listener-map access type-checked through one scoped test-only lint exception, preserving the lifecycle regression assertions. Refs microsoft#333186.

Co-authored-by: Copilot <[email protected]>
@dmitrivMS

Copy link
Copy Markdown
Collaborator

Simon Siefke (@SimonSiefke) Thank you!

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 multi-diff-editor Multi diff editor issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multifile diff editor leaks models and editor after closing and hiding

5 participants