I want to free up memory my ViewController used after dismissing it. I use the following code to present the new ViewController and dismiss the old one:
let sB: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let newVC: UIViewController = sB.instantiateViewController(withIdentifier: "MyVC")
self.present(newVC, animated: true, completion: { x in
oldVC.dismiss(animated: false, completion: { _ in //oldVC: variable keeping track of currently visible view controller
print("done")
})
})
This code successfully presents newVC
and prints done
after dismissing oldVC
. However, my memory still stays as high as it was when having oldVC
on screen.
What am I doing wrong?
FYI
- I am using ENSwiftSideMenu
- Since I didn't get it to work in a different way, all my ViewControllers are a subclass of ENSideMenuNavigationController
- I am getting console warnings about detached views and views not being in the window hierarchy
- for all ViewControllers, both
presentingViewController
andpresentedViewController
arenil
self
in each ViewController'sviewWillAppear(_:)
method. Hence, it is of type `UIViewController – Sacaton