Skip to content

fix: memory leak in pane composite bar#282589

Merged
dmitrivMS merged 10 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-pane-composite-bar
Jun 4, 2026
Merged

fix: memory leak in pane composite bar#282589
dmitrivMS merged 10 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-pane-composite-bar

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Fixes a memory leak in paneCompositeBar.

It seems the paneCompositeBar can be visible for a longer period of time, while it's actions can update many times.

private getCompositeActions(){
  // composite actions are updated, but the already registered ones not disposed here
  this.compositeActions.set(compositeId, compositeActions)
}

By changing the code to use a DisposableMap, it ensures that the previous actions are disposed when the actions are updated.

Before

When renaming a variable 97 times with refactor preview, it seems 3 actions are created each time:

editor rename-with-preview-before

After

When renaming a variable 97 times with refactor preview, no more action leaks are detected:

editor rename-with-preview

@vs-code-engineering

vs-code-engineering Bot commented Dec 10, 2025

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

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

@bpasero

Matched files:

  • src/vs/workbench/browser/parts/paneCompositeBar.ts

Copilot AI review requested due to automatic review settings March 13, 2026 09:30

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

This PR fixes a disposable leak in the workbench PaneCompositeBar by ensuring per-composite actions are properly lifecycle-managed when composites are hidden/removed and later re-created.

Changes:

  • Replace the compositeActions cache from a plain Map to a _register’d DisposableMap so cached action bundles are disposed when replaced/removed.
  • Stop _register’ing individual composite actions into the long-lived PaneCompositeBar store; instead dispose them via the map entry’s dispose().
  • Ensure all three actions (activityAction, pinnedAction, and badgeAction) are disposed when a composite is hidden/removed.

You can also share your feedback on Copilot code review. Take the survey.

@benibenj benibenj added this to the 1.113.0 milestone Mar 16, 2026
@benibenj benibenj removed this from the 1.113.0 milestone Mar 23, 2026
@dmitrivMS dmitrivMS enabled auto-merge (squash) May 31, 2026 01:00

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's findings

Comments suppressed due to low confidence (1)

src/vs/workbench/browser/parts/paneCompositeBar.ts:335

  • In the placeholder branch, toCompositeBarActionItem(...) is computed inline while constructing the activity action. If options.icon is enabled and the icon is a URI, this can also insert CSS rules; keeping it in a local actionItem avoids accidental repeated computation if this block is refactored/extended and keeps the pattern consistent with the non-placeholder branch.
			}

			const disposable = combinedDisposable(activityAction, pinnedAction, badgeAction);
			compositeActions = { activityAction, pinnedAction, badgeAction, dispose: () => disposable.dispose() };
			this.compositeActions.set(compositeId, compositeActions);
		}

		return compositeActions;
	}

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment thread src/vs/workbench/browser/parts/paneCompositeBar.ts Outdated
@dmitrivMS dmitrivMS disabled auto-merge May 31, 2026 01:00
@dmitrivMS

Copy link
Copy Markdown
Contributor

@SimonSiefke Thank you!

@dmitrivMS dmitrivMS enabled auto-merge (squash) May 31, 2026 01:03
@dmitrivMS dmitrivMS requested a review from benibenj May 31, 2026 01:03
@dmitrivMS dmitrivMS assigned dmitrivMS and unassigned benibenj May 31, 2026
@dmitrivMS dmitrivMS added the perf label May 31, 2026

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's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new

@dmitrivMS dmitrivMS disabled auto-merge May 31, 2026 12:45
@dmitrivMS dmitrivMS enabled auto-merge (squash) June 1, 2026 07:26
@dmitrivMS dmitrivMS merged commit 0f8c167 into microsoft:main Jun 4, 2026
39 of 40 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.124.0 milestone Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants