Swift - Deallocate previous view controller after segue
<p>I'm trying to find a proper way to handle my scene/view process flow in my game. I'm currently able to transition from a main menu to a game level, exit the game level and return to the main menu, but it's not deallocating any of the memory from any of the views.</p>

<p>I saw a lot of suggestions to use a <code>UINavigationController</code> to handle my view controllers. After trying that for a while, my current storyboard looks like this:</p>

<p><a href="https://i.stack.imgur.com/Ap405.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ap405.png" alt="Main.storyboard"></a></p>

<p>My root view controller is Menu View Controller. I first start in Title View Controller, segue to Menu View Controller, then segue to and from Game View Controller, but this is obviously not deallocating any of my memory.</p>

<p>My segues are done from within SKScenes using the following:</p>

<pre><code>self.viewController?.performSegueWithIdentifier("segueName", sender: viewController)
</code></pre>

<p>where viewController is a var within the SKScene referencing its parent view controller.</p>

<p>Is there something I could try to get my process flow to work out? I just want to be able to traverse a title scene for login and server connections, then spend the rest of the time switching between a menu scene and some sort of game scene.</p>

<p>I've tried to implement a few suggestions, for example, <code>dismissViewControllerAnimated(true, completion: nil)</code> but none of them seem to be actually deallocating anything. The game slows to a crawl after just 2-3 cycles between the menu scene and game scene.</p>

<p>I've seen quite a few questions similar to this, but I've been so far unable to come up with a solution that works for me. I'm writing a game in Swift and Xcode 7.3.1.</p>