title: How to properly release ViewControllers after user logout?
body: <p>I am trying to build an app supporting user login/logout.</p>
  
  <p>When the app launches I check if user is already logged in, and if so, I will directly segue to the main app, which is a tab bar based view; and if not, I will go to a login view and then perform a segue to main app after user logs in successfully. These work just fine.</p>
  
  <p>The problem is concerning when user logs out. There are two cases when user logs out:</p>
  
  <ol>
  <li>If users have already been to the login screen in this time's usage of the app, I can directly perform an unwind segue, and shown by the log I added inside deinit(), all the view controllers in the main app are released from memory. </li>
  <li>If users have never been to the login screen (which means when they launch the app they are already logged in, so main app shows directly without a login view), here comes the problem: If I directly perform a segue to login screen and the user logs in again, another 'new' main app will be created. Since the 'old' main app views are not released, the 'new' main app view actually doubles the memory. So how can I properly release all the existing main app view controllers after user logs out in this case?</li>
  </ol>