Skip to content

fix: memory leak in extension host tree view disposal - #338235

Merged
Dmitriy Vasyura (dmitrivMS) merged 3 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-treeView-disposal
Sep 28, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 3 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-treeView-disposal

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Disposing an extension tree view removes its registration and disposes the internal view, but leaves both the public view and internal view in the extension host service lifetime store. Old providers and view state stay there until service shutdown.

Change

Remove the public view from the service store and remove and dispose the internal view when the API view is disposed. Preserve immediate re-registration and other live views.

Before

Creating a tree view, revealing an item, and disposing the view 37 times adds 37 old providers and internal views across 22 named growth rows. The service store grows from 4 to 78 registrations.

before

After

No more matching provider or tree-view growth is detected in the same 37-cycle test. The service store has no retired view registrations. Small unrelated object-shape differences remain.

Test Video

Seven tree-view creation, item reveal, and disposal cycles.

test.mp4

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

Copilot AI balanced review requested due to automatic review settings September 27, 2026 18:19

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

🟡 Changes recommended

The disposal path incorrectly leaves the public facade marked as a leaked disposable.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Fixes extension-host tree view objects remaining retained after disposal.

Changes:

  • Removes disposed public and internal tree views from the service store.
  • Adds disposal, re-registration, shutdown, and garbage-collection tests.
File Description
extHostTreeViews.ts Cleans up stored tree view registrations.
extHostTreeViewDisposal.test.ts Adds lifecycle regression coverage.

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

Comment thread src/vs/workbench/api/common/extHostTreeViews.ts
@dmitrivMS

Copy link
Copy Markdown
Collaborator

Simon Siefke (@SimonSiefke) Thank you!

@dmitrivMS Dmitriy Vasyura (dmitrivMS) added the tree-views Extension tree view issues label Sep 28, 2026
@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 9f1fd52 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-treeView-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 tree-views Extension tree view issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants