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

memory leak with addChild() #6

Open
d2vydov opened this issue Dec 9, 2019 · 3 comments
Open

memory leak with addChild() #6

d2vydov opened this issue Dec 9, 2019 · 3 comments

Comments

@d2vydov
Copy link

d2vydov commented Dec 9, 2019

there is a memory leak with AboutCoordinator - it is added as a child into UserListCoordinator

@pauljohanneskraft we discussed this with you in slack and you adviced to removeChild or override viewController for fix cycle.

but I see a little problem, if we have a lot of coordinations in a child coordinator, override a viewController is not a good solution I guess.

removeChild decision isn't simple - we should notify coordinator from view (viewController) about we should free coordinator (if user tapped to back button) and handle some transitions which throw out from its coordinator. and then we should remove parent when transitions has been success.

the both solutions are far from perfect, right?

I have a proposal, what do you think about CoordinatorAutoreleasable protocol with some method which takes some view controller notifies a main controller of this flow - like root controller, just not root. Ideally, of course, it will be perfect if we will be able to inherit some coordinator from this protocol and it will be deallocated automatically :)

@pauljohanneskraft
Copy link
Collaborator

I'm not sure I understand what you mean - can you elaborate on how adding another protocol will solve memory issues? A method would need to be called at some point - that cannot easily be done. An alternative would be to enable overriding of canBeRemovedAsChild. Feel free to open a MR once you have a working version, so we can start a discussion on how to solve this best.

@pauljohanneskraft
Copy link
Collaborator

The leak in AboutCoordinator can easily be fixed by overriding the viewController property with:

override var viewController: UIViewController! {
    rootViewController.viewControllers.first { $0 is AboutViewController }
}

I will open a MR today for that.

@calvingit
Copy link

Me too. Even build with XCoordinator v2.2.0, the child coordinator can't be removed when clicked the navigation bar back button. I have tried the way from @pauljohanneskraft , it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants