Skip to content

fix: memory leak in canceled tree drag transfers - #340845

Merged
Alex Ross (alexr00) merged 3 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-canceledTreeDragTransfers
Oct 13, 2026
Merged

Alex Ross (alexr00) merged 3 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-canceledTreeDragTransfers

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Canceling a tree drag leaves its completed transfer promise in both the renderer and extension-host drag-transfer maps. A completed provider request can therefore outlive the drag that owned it.

Change

Retire the exact drag operation on cancellation, replacement, or controller teardown. Clear its local transfer and notify the original extension-host controller to release the matching transfer.

Before

When canceling tree drags for 37 cycles, completed transfer records grow from 0 to 37 in both processes. The complete extension-host named-function chart shows the three callback rows for that transfer.

before

After

No more leak detected.

Test Video

test-video.webm

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

Copilot AI balanced review requested due to automatic review settings October 10, 2026 08:42
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Benjamin Christopher Simmonds (@benibenj)

Matched files:

  • src/vs/workbench/browser/parts/views/treeView.ts

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.

🟡 Changes recommended

The new cleanup is not connected to actual tree/controller disposal, leaving the teardown leak unresolved.

1 open finding
What changed in this PR

Fixes leaked tree drag-transfer records after canceled or replaced drags.

Changes:

  • Tracks and retires active drag operations across renderer and extension host.
  • Adds an RPC for releasing extension-host transfers.
  • Adds cancellation, disposal, replacement, and successful-drop tests.
File Description
src/​vs/​workbench/​test/​browser/​customTreeViewDragAndDrop.test.ts Tests renderer drag lifecycle cleanup.
src/​vs/​workbench/​common/​views.ts Adds the drag-release callback.
src/​vs/​workbench/​browser/​parts/​views/​treeView.ts Tracks and cancels active operations.
src/​vs/​workbench/​api/​test/​browser/​mainThreadTreeViews.test.ts Tests release forwarding.
src/​vs/​workbench/​api/​test/​browser/​extHostTreeViews.test.ts Tests extension-host transfer cleanup.
src/​vs/​workbench/​api/​common/​extHostTreeViews.ts Removes canceled or failed transfers.
src/​vs/​workbench/​api/​common/​extHost.protocol.ts Defines the release RPC.
src/​vs/​workbench/​api/​browser/​mainThreadTreeViews.ts Forwards releases to the extension host.

🧠 Review effort: Balanced


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

Comment thread src/vs/workbench/browser/parts/views/treeView.ts

@alexr00 Alex Ross (alexr00) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

@alexr00
Alex Ross (alexr00) enabled auto-merge (squash) October 12, 2026 14:01
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues tree-widget Tree widget issues workbench-dnd Drag-and-drop issues labels Oct 12, 2026
@alexr00
Alex Ross (alexr00) merged commit e29d835 into microsoft:main Oct 13, 2026
55 of 59 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.143.0 milestone Oct 13, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-canceledTreeDragTransfers branch October 13, 2026 09:40
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 tree-widget Tree widget issues workbench-dnd Drag-and-drop issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants