Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: memory leak in titleBarPart - #327552

Merged
Dmitriy Vasyura (dmitrivMS) merged 1 commit into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-menuBar
Jul 27, 2026
Merged

fix: memory leak in titleBarPart#327552
Dmitriy Vasyura (dmitrivMS) merged 1 commit into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-menuBar

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Each time the menu bar was hidden and shown, VS Code created a new CustomMenubarControl. The previous control's visibility listener was kept for the lifetime of the title bar, which also kept that control and its menu actions in memory.

Change

When removing a menu bar, clear its visibility listener and CustomMenubarControl together. The activity bar now uses its existing MutableDisposable as the sole owner, so replacing a control releases the previous instance.

Before

Before the change, toggling the menu bar 37 times left menu bar controls and their actions in memory, with counts growing after every toggle:

before

After

After the change, repeating the same 37 toggles reports no matching menu bar leak.

Test Video

test-video.webm

Copilot AI review requested due to automatic review settings July 26, 2026 22:22
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

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

Benjamin Christopher Simmonds (@benibenj)

Matched files:

  • src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
  • src/vs/workbench/browser/parts/titlebar/titlebarPart.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.

Pull request overview

Fixes menu bar controls and listeners being retained after visibility toggles.

Changes:

  • Clears title bar menu visibility listeners alongside the control.
  • Makes the activity bar’s MutableDisposable the control’s sole owner.

Reviewed changes

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

File Description
titlebarPart.ts Disposes menu visibility listeners when uninstalling the menu bar.
activitybarPart.ts Removes duplicate lifetime ownership of the menu control.

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) enabled auto-merge (squash) July 27, 2026 11:04
@dmitrivMS

Copy link
Copy Markdown
Collaborator

Simon Siefke (@SimonSiefke) Thank you!

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 7e1334b into microsoft:main Jul 27, 2026
29 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.132.0 milestone Jul 27, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-menuBar branch July 28, 2026 16:51
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Sep 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants