fix: memory leak in timeline providers by SimonSiefke · Pull Request #340881 · microsoft/vscode · GitHub
Skip to content

fix: memory leak in timeline providers - #340881

Merged
Logan Ramos (lramos15) merged 2 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-mainThreadTimelineProviderDisposal
Oct 12, 2026
Merged

Logan Ramos (lramos15) merged 2 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-mainThreadTimelineProviderDisposal

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Unregistering a timeline provider removes its service subscription, but leaves its change emitter in MainThreadTimeline's provider map. Customer teardown also needs to release these owned registrations.

Change

Dispose and delete the owned emitter on unregister, and use the same cleanup path for the customer's remaining provider IDs during disposal.

Before

When registering and unregistering timeline providers for 37 cycles, retired provider emitters rise from 0 to 37. The complete named-function chart reports a separate DomListener row and does not isolate the emitters.

before

After

Retired provider emitters stay at 0, while the live provider and services remain. The separate DomListener row is unchanged.

after

Test Video

test-video.webm

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

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

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 cleanup correctly addresses the leak and is covered by focused lifecycle tests.

0 open findings

What changed in this PR

Fixes timeline-provider emitter leaks during unregistration and customer teardown.

Changes:

  • Tracks provider emitters with DisposableMap.
  • Disposes emitters during unregister and teardown.
  • Adds lifecycle and regression tests.
File Description
src/​vs/​workbench/​api/​browser/​mainThreadTimeline.ts Implements emitter lifecycle cleanup.
src/​vs/​workbench/​api/​test/​browser/​mainThreadTimeline.test.ts Tests registration, cleanup, isolation, and disposal.

🧠 Review effort: Balanced


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

@lramos15
Logan Ramos (lramos15) merged commit 3628abd 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-mainThreadTimelineProviderDisposal branch October 13, 2026 09:39
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