Dismiss ViewController after transition to release memory
<p>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:</p>
<pre><code>let sB: UIStoryboard = UIStoryboard(name: &quot;Main&quot;, bundle: nil)
let newVC: UIViewController = sB.instantiateViewController(withIdentifier: &quot;MyVC&quot;)
self.present(newVC, animated: true, completion: { x in
    oldVC.dismiss(animated: false, completion: { _ in //oldVC: variable keeping track of currently visible view controller
        print(&quot;done&quot;)
    })
})
</code></pre>
<p>This code successfully presents <code>newVC</code> and prints <code>done</code> after dismissing <code>oldVC</code>. However, my memory still stays as high as it was when having <code>oldVC</code> on screen.<br />
What am I doing wrong?</p>
<h2>FYI</h2>
<ul>
<li>I am using <a href="https://github.com/evnaz/ENSwiftSideMenu" rel="noreferrer">ENSwiftSideMenu</a>
<ul>
<li>Since I didn't get it to work in a different way, <strong>all my  ViewControllers are a subclass of ENSideMenuNavigationController</strong></li>
</ul>
</li>
<li>I am getting console warnings about detached views and views not being in the window hierarchy</li>
<li>for all ViewControllers, both <code>presentingViewController</code> and <code>presentedViewController</code> are <code>nil</code></li>
</ul>