[ios] fix memory leak in WindowOverlay#16700
Merged
rmarinho merged 1 commit intodotnet:mainfrom Aug 14, 2023
Merged
Conversation
Context: dotnet#16346 This addresses the memory leak discovered by: src/Core/src/WindowOverlay/WindowOverlay.iOS.cs(92,40): error MA0001: Event 'OnTouch' could cause memory leaks in an NSObject subclass. Remove the event or add the [UnconditionalSuppressMessage("Memory", "MA0001")] attribute with a justification as to why the event will not leak. I could reproduce a leak by writing a custom test. Solved the problem by: * Removed the `PassthroughView.OnTouch` event completely. We could just call `WindowOverlay.OnTappedInternal()` directly instead of going through an intermediate event. * `WindowOverlay overlay` is now a `WeakReference<WindowOverlay>`.
jsuarezruiz
approved these changes
Aug 11, 2023
Contributor
|
Waiting the build but looks nice so far. |
rmarinho
approved these changes
Aug 14, 2023
rmarinho
pushed a commit
that referenced
this pull request
Aug 19, 2023
Context: #16346 This addresses the memory leak discovered by: src/Core/src/WindowOverlay/WindowOverlay.iOS.cs(92,40): error MA0001: Event 'OnTouch' could cause memory leaks in an NSObject subclass. Remove the event or add the [UnconditionalSuppressMessage("Memory", "MA0001")] attribute with a justification as to why the event will not leak. I could reproduce a leak by writing a custom test. Solved the problem by: * Removed the `PassthroughView.OnTouch` event completely. We could just call `WindowOverlay.OnTappedInternal()` directly instead of going through an intermediate event. * `WindowOverlay overlay` is now a `WeakReference<WindowOverlay>`.
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context: #16346
This addresses the memory leak discovered by:
I could reproduce a leak by writing a custom test.
Solved the problem by:
Removed the
PassthroughView.OnTouchevent completely. We could just callWindowOverlay.OnTappedInternal()directly instead of going through an intermediate event.WindowOverlay overlayis now aWeakReference<WindowOverlay>.