Skip to content

fix: memory leak in test observer disposal - #338213

Merged
Dmitriy Vasyura (dmitrivMS) merged 1 commit into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-testObserver-disposal
Sep 29, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 1 commit into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-testObserver-disposal

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Test observers share a test collection, but disposing one observer leaves its event listeners attached while another observer keeps the collection open. The disposed observer continues receiving test changes.

Change

Route each observer’s events through its own disposable relay and dispose that relay with the observer. Other live observers continue using the shared collection.

Before

Keeping one observer live while creating, subscribing, and disposing 37 temporary observers grows the shared collection’s listener list from 2 to 39.

before

After

No more leak detected.

Test Video

Seven temporary observer creation, subscription, and disposal cycles with a live peer.

test.mp4

AI disclosure: Model: GPT 6 Astra. Worktime: 29 min

Copilot AI balanced review requested due to automatic review settings September 27, 2026 17: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.

Copilot review overview

🟢 Approval recommended

The scoped relay correctly removes listeners without disrupting live observers, with focused regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes test-observer listener leaks by giving each observer an independently disposable event relay.

Changes:

  • Route shared collection events through observer-scoped relays.
  • Add lifecycle and event-delivery regression tests.
File Description
src/​vs/​workbench/​api/​common/​extHostTesting.ts Disposes observer-specific event subscriptions.
src/​vs/​workbench/​api/​test/​browser/​extHostTesting.test.ts Tests disposal, resubscription, and collection lifecycle.

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

@dmitrivMS

Copy link
Copy Markdown
Collaborator

Simon Siefke (@SimonSiefke) Thank you!

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit e9e3b06 into microsoft:main Sep 29, 2026
35 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.141.0 milestone Sep 29, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-testObserver-disposal branch September 29, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues testing Built-in testing support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants