Conversation
If an update has already been queued for processing (but not yet completed), simply skip queuing another update.
Keboo
approved these changes
Mar 25, 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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #4003
This PR fixes (or at least drastically improves) the memory leak mentioned in the issue. Basically, the code was blindly queuing new updates of the attached property on every layout update. When resizing a window or doing something else causing a lot of layout events, this would "congest" the message pump with essentially the same lambda.
This PR introduces a flag
_uiUpdateInProgresswhich is set once an update is being queued, and cleared once an update has finished. If a layout change happens in between, it is simply ignored.The below shows the memory usage captured in the Visual Studio diagnostics tools before/after the fix. The reproduction step was to open the app (from the linked issue), and repeatedly resize the window.
Memory usage before the fix (continuous growth, insane number of GC calls, no drop-down to "normal" after resizing finishes):

Memory usage after the fix (still growth which is expected, much fewer GC calls, and a drop-down to "normal" after resizing finishes):
