Kodr.F
Kodr.F

Reputation: 14400

iOS Swift popViewController not released from memory?

i am having issue with closing UIViewcontroller which is attached and opened from uiNavigationController , when i close/reopen the B UIViewcontroller the memory get increased every time i open it , but when i close it nothing happened the memory wont go down .

I've tried the following codes all same :

DispatchQueue.main.async {[weak self] in
    guard let strongSelf = self else { return }
    strongSelf.navigationController?.pushViewController(vc, animated: true)
}

and

DispatchQueue.main.async {[unowned self] in
    self.navigationController?.pushViewController(vc, animated: true)
}

and

self.navigationController?.pushViewController(vc, animated: true)

the B UIViewctonroller has only 1 image in storyboard no code is there .

anyidea how to release Closed "pop" UIVIewcontroller from memory ?

Upvotes: 1

Views: 1208

Answers (1)

Sanad Barjawi
Sanad Barjawi

Reputation: 578

  • make sure you didn't set any strong pointers to that viewController (like navigation controller for example), otherwise that controller will get retained by the navigation controller
  • Try to avoid using strong properties for IBOutlets.

  • if your using self in your code make sure it's an optional self, using the [weak self] Swift Blocks It will be be released if there are no other strong pointers to it

Upvotes: 1

Related Questions