-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ios/catalyst] fix memory leaks in
*Cell
(#22067)
* [ios/catalyst] fix memory leaks in `*Cell` Context: https://github.com/AdamEssenmacher/MemoryToolkit.Maui/tree/main/samples Retesting this sample with the `ListView` leak fixed, I noticed the sample reports 0 leaks! Unfortunately, it still displayed memory growing over time... Taking a `.gcdump` snapshot, I noticed a cycle: * `ViewCellRenderer.ViewTableCell` -> `ViewCell _viewCell` -> `ViewCellRenderer` -> `ViewTableCell` I was able to write a test that reproduces the leak, and I extended it for every type of `*Cell` like `TextCell`, `ImageCell`, `SwitchCell`, etc. The fixes are: * `ViewTableCell` now uses a `WeakReference<ViewCell> _viewCell` * `CellTableViewCell` now uses a `WeakReference<Cell> _cell` * `CellTableViewCell` now uses a `WeakEventManager` for `PropertyChanged`, as the `*Renderer` subscribes to this event. Note that I changed `PropertyChanged` to an event, which is an API change. (I can revisit this if needed) * Fixed all public API changes * Better null checking One test was crashing (even on rerun), so maybe this will fix * - add null check for ImageCellRenderer * - wire everything up through handler paths * - cleanup * Update CellTableViewCell.cs * - add additional unshipped --------- Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
- Loading branch information
1 parent
f2cc45e
commit e7f8467
Showing
11 changed files
with
145 additions
and
103 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
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
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
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
Oops, something went wrong.