Repository navigation
fix: memory leak in utilityProcessWorkerMainService - #294005
Merged
Dmitriy Vasyura (dmitrivMS) merged 13 commits intoMay 7, 2026
Merged
Dmitriy Vasyura (dmitrivMS) merged 13 commits into
Dmitriy Vasyura (dmitrivMS) merged 13 commits into
Conversation
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Benjamin Pasero (@bpasero)Matched files:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a memory leak in the Electron main-process UtilityProcessWorkerMainService by ensuring worker instances are disposed when their underlying utility process terminates, rather than only removing them from the tracking map.
Changes:
- Replace the internal
Mapof workers with a registeredDisposableMapto manage worker lifecycles. - Dispose workers on termination via
deleteAndDisposein the termination handler. - Simplify
disposeWorkerto only request termination (kill()), relying on the termination pathway for cleanup.
If deleteAndDispose throws, the deferred promise would never complete, leaving awaiters hanging. Reorder so the promise completes first. Co-authored-by: Copilot <[email protected]>
disposeWorker -> kill() is async, so a previous worker for the same id can terminate after a new worker has already taken its slot in the map. Guard the deletion with an identity check and dispose the worker directly. Co-authored-by: Copilot <[email protected]>
Dmitriy Vasyura (dmitrivMS)
enabled auto-merge (squash)
May 3, 2026 21:01
Dmitriy Vasyura (dmitrivMS)
approved these changes
May 7, 2026
roblourens
approved these changes
May 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a memory leak in
utilityProcessWorkerMainService.Details
In
utilityProcessWorkerMainService, when a worker is terminated, it is removed from thethis.workersmap. But the worker itself seems be not be disposed.Change
The change uses a
DisposableMapso that the worker is be deleted from the map and also gets disposed.Another related (but not really important) change is removing some cleanup code from
disposeWorkerwhich seems to be already handled byworker.onDidTerminate.Before
When opening and closing a window 17 times, the number of various utility process functions seems to grow each time.
After
When opening and closing a window 17 times, the number of utility process functions stays constant: