Skip to content

fix: memory leak in extension host pseudoterminals - #333397

Merged
Megan Rogge (meganrogge) merged 1 commit into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-extension-host-pseudoterminal-disposal
Aug 31, 2026
Merged

fix: memory leak in extension host pseudoterminals#333397
Megan Rogge (meganrogge) merged 1 commit into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-extension-host-pseudoterminal-disposal

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Closing an extension-owned terminal removes the terminal API object, but process cleanup only runs from the pseudoterminal's onDidClose event. A pseudoterminal does not have to provide that event, so its process entry, buffered-data subscription, and event listeners remain after the terminal closes.

Change

Run process cleanup from both the terminal-close path and the process-exit path. Include the pseudoterminal, its event subscriptions, and the data-buffer subscription in the process disposable, and skip listener setup if the terminal closed before setup completed.

Before

When creating and disposing an extension pseudoterminal 37 times, the pseudoterminal, terminal API object, and callbacks grow each time:

before-pseudoterminal

After

No more extension host pseudoterminal leak is detected.

Test Video

go-progress-terminal.webm

Copilot AI balanced review requested due to automatic review settings August 30, 2026 14:16

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 extension-host pseudoterminal resource leaks during terminal closure and process exit.

Changes:

  • Tracks pseudoterminal listeners and buffered-data subscriptions for disposal.
  • Cleans process resources from both closure paths.
  • Adds regression coverage for terminal-close cleanup.

Reviewed changes

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

File Description
extHostTerminalService.ts Adds pseudoterminal lifecycle cleanup.
extHostTerminalService.test.ts Tests cleanup after terminal closure.

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

Comment thread src/vs/workbench/api/common/extHostTerminalService.ts
@SimonSiefke
Simon Siefke (SimonSiefke) force-pushed the fix/memory-leak-extension-host-pseudoterminal-disposal branch from 8fa001c to 481d87f Compare August 30, 2026 14:25

@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.

Thank you!

@meganrogge
Megan Rogge (meganrogge) merged commit 4d3de9d into microsoft:main Aug 31, 2026
27 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.137.0 milestone Aug 31, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-extension-host-pseudoterminal-disposal branch September 1, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants