Skip to content

fix: memory leak in composite drag and drop registrations - #338215

Merged
Dmitriy Vasyura (dmitrivMS) merged 2 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-compositeDragDrop-registrations
Sep 28, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 2 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-compositeDragDrop-registrations

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Each drag source or drop target registration adds its disposal store to the process-lifetime observer as well as returning it to the caller. Disposing the registration clears its callbacks but leaves the empty store and its Set in the observer.

Change

Return each registration store to its existing caller owner without adding it to the observer’s lifetime store. The caller continues to dispose its drag source or drop target normally.

Before

Toggling Modern UI on and off 37 times after warmup grows the observer’s disposed registration stores from 471 to 915. The full aggregate Set measurement below grows from 26,550 to 26,987 entries; it includes unrelated Sets too.

before

After

The same 37-cycle test leaves no registration stores in the observer. The full aggregate Set measurement stays at 26,051 entries, and overall DisposableStore growth falls from 447 to 4. Undo history and other object-shape differences remain. This fixes empty bookkeeping objects, not callbacks or widgets that disposal already released.

after

Test Video

Seven Modern UI enable/disable cycles in Settings after the same setup warmup.

test.mp4

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

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

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

All production callers retain and dispose the returned registrations, and the tests cover lifecycle regressions.

Review effort: Balanced
Findings: None

What changed in this PR

Prevents process-lifetime retention of disposed composite drag-and-drop registration stores.

Changes:

  • Returns registration stores directly to caller owners.
  • Adds GC, disposal, and drag lifecycle regression tests.
File Description
src/​vs/​workbench/​browser/​dnd.ts Removes observer ownership of per-registration stores.
src/​vs/​workbench/​test/​browser/​compositeDragAndDropObserver.test.ts Tests collection, disposal, and event behavior.

💡 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 bef11ba into microsoft:main Sep 28, 2026
35 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.141.0 milestone Sep 28, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-compositeDragDrop-registrations 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 workbench-dnd Drag-and-drop issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants