Skip to content

fix: memory leak in notebook serializer disposal - #338212

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

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

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Disposing a notebook serializer registration unregisters it from the main thread but leaves the provider in the extension host serializer registry. Old serializers remain there after their notebooks close and can still handle requests using disposed registration handles.

Change

Delete the serializer registry entry before unregistering it from the main thread. Preserve other live serializers and allow operations that already started to finish without restoring the registration.

Before

Registering a serializer, opening and closing its notebook, and disposing the registration 37 times adds 37 old serializers. The extension host registry grows from 2 to 39 provider entries.

before

After

No more serializer growth is detected in the same 37-cycle test. The registry stays empty at both snapshots and the named growth result is empty. Small unrelated array and object differences remain in the full heap comparison.

Test Video

Seven serializer registration, notebook open/close, and registration disposal cycles.

test.mp4

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

Copilot AI balanced review requested due to automatic review settings September 27, 2026 17:23

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 focused lifecycle fix addresses the leak without disrupting in-flight operations and has appropriate regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes retained notebook serializers in the extension host after registration disposal.

Changes:

  • Removes disposed serializers from the extension-host registry before main-thread unregistration.
  • Adds lifecycle, isolation, idempotency, and in-flight operation tests.
File Description
src/​vs/​workbench/​api/​common/​extHostNotebook.ts Deletes the serializer registry entry during disposal.
src/​vs/​workbench/​api/​test/​browser/​extHostNotebookSerializer.test.ts Verifies serializer disposal behavior and request handling.

💡 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 319659f 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-notebookSerializer-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 notebook-serialization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants