Skip to content

fix: memory leak in chat debug providers - #340880

Merged
Michael Lively (Yoyokrazy) merged 3 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-chatDebugCustomerDisposal
Oct 12, 2026
Merged

Michael Lively (Yoyokrazy) merged 3 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-chatDebugCustomerDisposal

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

MainThreadChatDebug stores each provider's registration resources in a plain map. Its inherited disposal does not dispose those stores after an extension-host restart, leaving old providers and historical fetchers registered in ChatDebugService.

Change

Store provider registrations in a registered DisposableMap so customer teardown disposes every owned store. Use deleteAndDispose for normal unregister and clear active-session resources during teardown.

Before

When restarting the extension host for 37 cycles, retired provider registrations, historical fetchers, and registration stores each rise from 0 to 37. The complete chart also includes customer wrappers held by a separate task-service path.

before

After

The three retired resource kinds stay at 0 and all four provider callback rows disappear. There are 148 other chart rows, including the customer constructor. This change releases provider resources; it does not fix the separate customer-wrapper path.

after

Test Video

test-video.webm

AI disclosure: Model: GPT-6.1-Sol. Worktime: 13 min

Copilot AI balanced review requested due to automatic review settings October 10, 2026 19:29

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 lifecycle changes correctly dispose provider registrations without altering normal behavior.

0 open findings

What changed in this PR

Fixes chat debug provider leaks during extension-host teardown.

Changes:

  • Tracks provider resources in a registered DisposableMap.
  • Disposes registrations on unregister and clears session-resource state on teardown.
File Description
src/​vs/​workbench/​api/​browser/​mainThreadChatDebug.ts Ensures chat debug provider resources are disposed correctly.

🧠 Review effort: Balanced


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

@Yoyokrazy
Michael Lively (Yoyokrazy) merged commit 0b9ae1f into microsoft:main Oct 12, 2026
35 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.143.0 milestone Oct 12, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-chatDebugCustomerDisposal branch October 13, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants