Skip to content

fix: memory leak in terminal profile service - #334100

Merged
Megan Rogge (meganrogge) merged 1 commit into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-terminalProfileService
Sep 3, 2026
Merged

Megan Rogge (meganrogge) merged 1 commit into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-terminalProfileService

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Registering a terminal profile provider adds it to the profile service map for its extension. Disposing the registration deletes the provider ID from the outer extension map instead of the nested provider map, so the provider remains registered.

Change

Delete the provider from the extension nested map and remove the map when it becomes empty.

Before

When registering and disposing a terminal profile provider 37 times, createContributedTerminalProfile grows by 37:

terminal-profile-before

After

No more terminal profile provider callback leak is detected.

Test Video

terminal-profile-test-video.webm

Copilot AI balanced review requested due to automatic review settings September 2, 2026 19:56
@vs-code-engineering

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/terminal/browser/terminalProfileService.ts
  • src/vs/workbench/contrib/terminal/test/browser/terminalProfileService.integrationTest.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

The focused fix correctly addresses the leak and includes appropriate regression coverage.

Pull request overview

Fixes terminal profile provider cleanup to prevent retained callbacks.

Changes:

  • Removes disposed providers from the nested extension map.
  • Removes empty extension maps.
  • Adds regression coverage for provider isolation and disposal.
File summaries
File Description
terminalProfileService.ts Corrects provider disposal logic.
terminalProfileService.integrationTest.ts Verifies disposed providers are removed without affecting others.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@meganrogge Megan Rogge (meganrogge) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@meganrogge
Megan Rogge (meganrogge) merged commit 0ad3373 into microsoft:main Sep 3, 2026
30 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.137.0 milestone Sep 3, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-terminalProfileService branch September 20, 2026 07:39
Abdon Morales (abdonmorales) pushed a commit to abdonmorales/vscode-utcs that referenced this pull request Sep 23, 2026
fix: dispose terminal profile providers
(cherry picked from commit 0ad3373)
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Oct 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants