Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[iOS] Fix: memory leak when Navigation.RemovePage is used #5695

Merged
merged 4 commits into from
May 8, 2019

Conversation

kicsiede
Copy link
Contributor

@kicsiede kicsiede commented Mar 26, 2019

The leak occurs in a MasterDetailPage.Detail = NavigationPage(ContentPage) scenario if the ContentPage has ToolBarItems. (ToolBarItems create a strong dependency therefore the ViewController of the NavigationPage must be explicitly disposed)

Description of Change

disposing viewcontroller in RemovePage.

Platforms Affected

  • iOS

Testing Procedure

PR Checklist

  • Has automated tests
  • Rebased on top of the target branch at time of PR
  • Changes adhere to coding standard

The leak occurs in a MasterDetailPage.Detail = NavigationPage(ContentPage) scenario if the ContentPage has ToolBarItems. (ToolBarItems create a strong dependency therefore the ViewController of the NavigationPage must be explicitly disposed)
@andreinitescu
Copy link
Contributor

andreinitescu commented Mar 26, 2019

@kicsiede Just a suggestion, adding an unit test for this would be great...

It's really awesome you were able to find and track this down, memory leaks are 😨

@rmarinho
Copy link
Member

Hey do you think you can you add a UITest ?!

thanks

@kicsiede
Copy link
Contributor Author

@rmarinho please check

namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 5555, "Memory leak when SwitchCell or EntryCell", PlatformAffected.iOS)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy/paste detected =)
I'll think about something more universal for any controls when checking for memory leaks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I was gonna say we had a test for most of the renderers where we pushed a page with a control, and make sure it was collected, I wonder if we can do that in the dynamic gallery test you created Pavel

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paymicro @rmarinho fyi here it is not the control causing the leak but the RemovePage method.

@samhouts samhouts changed the base branch from master to 4.0.0 March 27, 2019 23:31
@samhouts samhouts changed the base branch from 4.0.0 to master March 27, 2019 23:31
@rmarinho rmarinho merged commit 247f758 into xamarin:master May 8, 2019
@samhouts samhouts added this to the 4.1.0 milestone Jun 4, 2019
@samhouts samhouts added the approved Has two approvals, no pending reviews, and no changes requested label Jul 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Has two approvals, no pending reviews, and no changes requested p/iOS 🍎
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants