-
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.
[ios] fix memory leak in Picker (#16685)
Context: #16346 This addresses the memory leak discovered by: src/Core/src/Platform/iOS/MauiPicker.cs(21,24): error MA0002: Member 'UIPickerView' could cause memory leaks in an NSObject subclass. Remove the member, store the value as a WeakReference, or add the [UnconditionalSuppressMessage("Memory", "MA0002")] attribute with a justification as to why the member will not leak. I could reproduce a leak in `MemoryTests.cs`: ++[InlineData(typeof(Picker))] public async Task HandlerDoesNotLeak(Type type) Solved the problem by: * Introduce `MauiPickerProxy` for all event subscriptions. Same pattern as in other PRs. * The `ShouldBeginEditing` event was originally subscribed in `CreatePlatformView()` and never unsubscribed. I moved to be subscribed/unsubscribed the same way as the other events. * Refactored the `CreateAlert()` method to be `DisplayAlert()` instead. This allows the handler to do all the work -- and the `MauiPickerProxy` type can call a method on `PickerHandler` once.
- Loading branch information
1 parent
73271cc
commit 844b019
Showing
3 changed files
with
108 additions
and
66 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