Skip to content

Comments

[release/7.0.2xx] [net7.0] [core] WeakEventManager.RemoveEventHandler() should clear subscriptions#14074

Merged
rmarinho merged 3 commits intorelease/7.0.2xxfrom
backport/pr-13650-to-release/7.0.2xx
Mar 21, 2023
Merged

[release/7.0.2xx] [net7.0] [core] WeakEventManager.RemoveEventHandler() should clear subscriptions#14074
rmarinho merged 3 commits intorelease/7.0.2xxfrom
backport/pr-13650-to-release/7.0.2xx

Conversation

@github-actions
Copy link
Contributor

Backport of #13650 to release/7.0.2xx

/cc @rmarinho @github-actions[bot]

jonathanpeppers and others added 3 commits March 20, 2023 14:26
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();
This is closer to the standard `forr` snippet that has been around forever, just using `n` instead of `i`.
@rmarinho
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@rmarinho rmarinho merged commit 6e0d081 into release/7.0.2xx Mar 21, 2023
@rmarinho rmarinho deleted the backport/pr-13650-to-release/7.0.2xx branch March 21, 2023 10:52
@github-actions github-actions bot locked and limited conversation to collaborators Dec 12, 2023
@samhouts samhouts added the fixed-in-7.0.81 Look for this fix in 7.0.81! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

fixed-in-7.0.81 Look for this fix in 7.0.81! t/housekeeping ♻︎

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants