Skip to content
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

[ios] fix memory leaks in ContentView #15193

Closed

Commits on May 30, 2023

  1. [ios] fix memory leaks in ContentView

    Context: https://github.com/jonathanpeppers/MemoryLeaksOniOS
    Related to: dotnet#14664
    
    There are a couple cycles on iOS that causes memory leaks in all
    controls based on `ContentView`:
    
    * `Microsoft.Maui.Controls.ContentView` ->
        * `ContentViewHandler` ->
        * `Microsoft.Maui.Platform` ->
        * `CrossPlatformArrange/Measure` property ->
    * `Microsoft.Maui.Controls.ContentView` cycle
    
    To fix this, I made `CrossPlatformArrange/Measure` properties obsolete,
    using the weak `View` property directly instead. This applies to various
    other controls like `Border`, `RadioButton`, `SwipeItemView`, `SwipeView`.
    
    I did not yet fix `ScrollView` that appears to be more complicated to
    solve. For now, it supports both code paths.
    
    `ScrollView` will continue to have leaks in:
    
    * Closures with captured variables
        * https://github.com/dotnet/maui/blob/3b620952425ca3c4542c4632e05d09eb4f583e22/src/Core/src/Handlers/ScrollView/ScrollViewHandler.iOS.cs#L195
        * https://github.com/dotnet/maui/blob/3b620952425ca3c4542c4632e05d09eb4f583e22/src/Core/src/Handlers/ScrollView/ScrollViewHandler.iOS.cs#L227
    
    * `CrossPlatformArrange/Measure`
        * https://github.com/dotnet/maui/blob/3b620952425ca3c4542c4632e05d09eb4f583e22/src/Core/src/Handlers/ScrollView/ScrollViewHandler.iOS.cs#L182-L186
    jonathanpeppers authored and rmarinho committed May 30, 2023
    Configuration menu
    Copy the full SHA
    495de5b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7091309 View commit details
    Browse the repository at this point in the history