Skip to content

fix: memory leak in dialog main service - #336019

Open
Simon Siefke (SimonSiefke) wants to merge 2 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-dialogMainService-queues
Open

Simon Siefke (SimonSiefke) wants to merge 2 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-dialogMainService-queues

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Each window that shows a native dialog gets its own queue in DialogMainService. The queue is not removed after the dialog finishes and the window closes, so one queue remains for every window that has shown a dialog.

Change

Remove a per-window dialog queue when all of its work has finished. Dialogs that overlap for the same window still share the queue and run in order.

Before

After 37 measured cycles of opening a window, invoking About, and closing the window, named-function-count3 reports 37 additional Queue allocations. Heap retaining paths lead through DialogMainService.windowDialogQueues. The outlined Queue row identifies the growth removed by this change.

Both revisions use the same main-process scenario and a growth threshold of 37. The usual async.ts and event.ts exclusions are disabled so queue and emitter allocations are visible. Black bars show the initial count, red bars show growth, and labels show the final count.

dialog-queues-named-before

After

With the same 37 measured cycles, Queue growth is 0. The raw heaps contain 2 Queue instances before and after, belonging to configuration editing and the no-window dialog queue. No queues remain retained through windowDialogQueues. Other event and storage allocations still grow and remain visible below.

dialog-queues-named-after

Test Video

test-video.webm

Copilot AI balanced review requested due to automatic review settings September 13, 2026 08:54

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 encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Note

This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants