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 leak in Border #15946

Merged
merged 1 commit into from
Jun 30, 2023
Merged

Conversation

jonathanpeppers
Copy link
Member

Context: #14664
Context: https://github.com/nacompllo/MemoryLeakEverywhere/tree/bugfix/memoryLeakItemsSource

While looking at the customer sample, we found an issue with BorderHandler:

  • ContentView -> via LayoutSubviewsChanged
  • BorderHandler ->
  • ContentView

Creating a cycle & memory leak on iOS and Catalyst. We could reproduce this in a device test.

It appears the event only did this:

void OnLayoutSubviewsChanged(object? sender, EventArgs e)
{
    PlatformView?.UpdateMauiCALayer();
}

And so instead, we can just call the extension method directly:

this.UpdateMauiCALayer();

And the leak is gone!

We are not sure if #14664 will be fully solved by this change, but it is one issue in the sample.

Context: dotnet#14664
Context: https://github.com/nacompllo/MemoryLeakEverywhere/tree/bugfix/memoryLeakItemsSource

While looking at the customer sample, we found an issue with
`BorderHandler`:

* `ContentView` -> via `LayoutSubviewsChanged`
* `BorderHandler` ->
* `ContentView`

Creating a cycle & memory leak on iOS and Catalyst. We could reproduce
this in a device test.

It appears the event only did this:

    void OnLayoutSubviewsChanged(object? sender, EventArgs e)
    {
        PlatformView?.UpdateMauiCALayer();
    }

And so instead, we can just call the extension method directly:

    this.UpdateMauiCALayer();

And the leak is gone!

Co-authored-by: Haritha Mohan <harithamohan@microsoft.com>
@jonathanpeppers jonathanpeppers added platform/iOS 🍎 legacy-area-perf Startup / Runtime performance labels Jun 30, 2023
@jonathanpeppers jonathanpeppers marked this pull request as ready for review June 30, 2023 18:21
@PureWeen PureWeen merged commit d211b85 into dotnet:main Jun 30, 2023
@jonathanpeppers jonathanpeppers deleted the iOSBorderLeak branch July 1, 2023 00:17
@jonathanpeppers jonathanpeppers added memory-leak 💦 Memory usage grows / objects live forever and removed legacy-area-perf Startup / Runtime performance labels Jul 12, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2023
@samhouts samhouts added the fixed-in-8.0.0-preview.7.8842 Look for this fix in 8.0.0-preview.7.8842! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed-in-8.0.0-preview.7.8842 Look for this fix in 8.0.0-preview.7.8842! memory-leak 💦 Memory usage grows / objects live forever platform/iOS 🍎
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants