Skip to content

fix: memory leak in mapped edit provider disposal - #338245

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

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

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Disposing a mapped-edit provider unregisters it in the renderer but leaves its entry in the extension host provider map. Repeated registration and disposal accumulates old providers.

Change

Delete the provider entry when its registration is disposed, before unregistering it in the renderer. Preserve the existing behavior of requests already in progress.

Before

Registering and disposing a mapped-edit provider 37 times adds 37 old provider objects. The provider map grows from 2 to 39 entries.

before

After

No more mapped-edit provider growth is detected in the same 37-cycle test. The provider map stays empty after disposal. Small unrelated object and promise differences remain in the full shape comparison.

Test Video

Seven mapped-edit provider registration and disposal cycles through the extension API.

test.mp4

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

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

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

Provider deletion can race with renderer requests already in transit.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Fixes retention of disposed mapped-edit providers in the extension host.

Changes:

  • Removes providers from the map during disposal.
  • Adds provider lifecycle and in-flight request tests.
File Description
extHostCodeMapper.ts Deletes disposed provider entries.
extHostCodeMapper.test.ts Tests registration, disposal, and request behavior.

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

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

Copy link
Copy Markdown
Collaborator

Simon Siefke (@SimonSiefke) Thank you!

auto-merge was automatically disabled September 28, 2026 06:35

Pull request was closed

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 509aa24 into microsoft:main Sep 28, 2026
66 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-mappedEdits-providerDisposal branch September 29, 2026 11:15
Abdon Morales (abdonmorales) pushed a commit to abdonmorales/vscode-utcs that referenced this pull request Oct 1, 2026
* Fix disposed mapped-edit providers retained in extension host

* fix: retain mapped edit providers until unregistration settles

---------

Co-authored-by: Dmitriy Vasyura <dmitriv@microsoft.com>
(cherry picked from commit 509aa24)
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants