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 #72

Closed
fanglinwei opened this issue Aug 11, 2020 · 5 comments
Closed

Memory leak #72

fanglinwei opened this issue Aug 11, 2020 · 5 comments

Comments

@fanglinwei
Copy link

Describe the bug
A clear and concise description of what the bug is.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots, videos or sample codes
If applicable, add screenshots to help explain your problem.

Environnement :

  • Device: iPhoneX
  • OS: iOS 13.6
  • OverlayContainer Version 3.5.0

Additional context
Add any other context about the problem here.

image

window?.rootViewController = UINavigationController(rootViewController: TestViewController())
navigationController?.pushViewController(ShowOverlayExampleViewController(), animated: true)

ShowOverlayExampleViewController popViewController deinit does not execute

image

@gaetanzanella
Copy link
Contributor

when do you pop your view controller?

@fanglinwei
Copy link
Author

when do you pop your view controller?

When I clicked the system launch button pop ShowOverlayExampleViewController in the upper left corner, I found that ShowOverlayExampleViewController did not execute deinit.

@fanglinwei
Copy link
Author

when do you pop your view controller?

My simple guess is that overlayPresentationController may cause memory leaks

@gaetanzanella
Copy link
Contributor

Interesting. The leak exists as soon as you call presentationController:

class TestViewController: UIViewController {

    // MARK: - Life Cycle

    init() {
        super.init(nibName: nil, bundle: nil)
        view.backgroundColor = .systemRed
    }

    @available(*, unavailable)
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        super.touchesBegan(touches, with: event)
        let controller = PushedViewController()
        let presentationController = controller.presentationController
        navigationController?.pushViewController(controller, animated: true)
    }
}

class PushedViewController: UIViewController {

    // MARK: - Life Cycle

    init() {
        super.init(nibName: nil, bundle: nil)
        view.backgroundColor = .systemBlue
    }

    deinit {
        print("Deinit") // never called
    }

    @available(*, unavailable)
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
} 

@gaetanzanella
Copy link
Contributor

Here is a fix. I don't like it but I will release it if I do not find something better. Thanks for pointing me the issue! It is critical.

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

2 participants