Skip to content

fix: memory leak in historyService - #327518

Merged
Dmitriy Vasyura (dmitrivMS) merged 4 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-historyService
Jul 31, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 4 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-historyService

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

HistoryService kept disposal callbacks for editor inputs in editorHistoryListeners after they ran. Disposed custom editor inputs therefore stayed reachable and retained their custom editor models and overlay webviews.

Change

Delete and dispose the listener-map entry when the editor's onWillDispose event fires, before running the history callback.

Before

When running debug-javascript-performance-profile 37 times, custom editor models, overlay webviews, and their retaining callbacks grow (outlined in red):

historyService-before

After

No more custom editor model, overlay webview, or retaining callback growth is detected.

historyService-after

Test Video

historyService-test-video.webm

Copilot AI review requested due to automatic review settings July 26, 2026 14:02

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.

Pull request overview

Fixes a HistoryService memory leak by removing editor disposal listener entries after execution.

Changes:

  • Deletes and disposes listener-map entries before invoking disposal callbacks.
  • Adds regression coverage verifying listener cleanup.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
historyService.ts Cleans up editor disposal listener entries.
historyService.test.ts Tests listener-map cleanup after editor disposal.

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) enabled auto-merge (squash) July 31, 2026 00:59
@dmitrivMS

Copy link
Copy Markdown
Collaborator

Simon Siefke (@SimonSiefke) Thank you!

@deepak1556 Robo (deepak1556) added this to the 1.132.0 milestone Jul 31, 2026
@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit c41c978 into microsoft:main Jul 31, 2026
29 checks passed
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-historyService branch August 13, 2026 20:14
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Sep 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants