-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release/7.0.2xx] [net7.0] [core] WeakEventManager.RemoveEventHandler…
…() should clear subscriptions (#14074) * [core] WeakEventManager.RemoveEventHandler() should clear subscriptions Context: #12039 Context: https://github.com/Vroomer/MAUI-master-detail-memory-leak Context: https://github.com/symbiogenesis/Maui.DataGrid/tree/memory-leak Reviewing memory snapshots in the above apps, sometimes I would see new `WeakEventManager+Subscription` objects be created and never go away. I noticed the `WeakEventManager.RemoveEventHandler()` method did not remove any `Subscription` entries that it encountered were no longer alive. I could reproduce this problem in a test, and improved an existing test to check this collection is cleared appropriately: readonly Dictionary<string, List<Subscription>> _eventHandlers = new(); * Remove the `n - 1` business This is closer to the standard `forr` snippet that has been around forever, just using `n` instead of `i`. * - add null forgiveness to test --------- Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com> Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
- Loading branch information
1 parent
824e533
commit 6e0d081
Showing
2 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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