-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Make IShape in MauiCALayer a WeakReference #28412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make IShape in MauiCALayer a WeakReference #28412
Conversation
Hey there @MarcelStommel! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have some specific tests to verify that controls not leaks here
[InlineData(typeof(RoundRectangle))] |
But, not cover the scenario from https://github.com/MarcelStommel/LayerLeak/
Could you include a new test?
public class ShapeTests |
Added the Device Test as part of BorderTests, since that's also how I did it in https://github.com/MarcelStommel/LayerLeak/ (Sorry about the other GitHub account, I just had to test it on my private MacBook and that was just the easiest way to get the changes pushed.) |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
* Make IShape in MauiCALayer a WeakReference * Added DeviceTest --------- Co-authored-by: Rain336 <rain336@live.de>
* Make IShape in MauiCALayer a WeakReference * Added DeviceTest --------- Co-authored-by: Rain336 <rain336@live.de>
* Make IShape in MauiCALayer a WeakReference * Added DeviceTest --------- Co-authored-by: Rain336 <rain336@live.de>
* Make IShape in MauiCALayer a WeakReference * Added DeviceTest --------- Co-authored-by: Rain336 <rain336@live.de>
* Make IShape in MauiCALayer a WeakReference * Added DeviceTest --------- Co-authored-by: Rain336 <rain336@live.de>
Description of Change
Fixes a memory leak in
MauiCALayer
by making it'sIShape? _shape
field a weak reference, as proposed in the attached Issue.The leak happens from the fact that most
IShape
s are alsoView
s and thereby have access to the UI'sNameScope
andx:Name
ed elements, which causes a ref-count cycle.Issues Fixed
Fixes #26169
App to reproduce the memory leak / Test the fix: https://github.com/MarcelStommel/LayerLeak