This is the Navigation Stack of my App. New User
Existing User (Already Logged in user)
How should I create a segue so that there is no memory leak? When the user clicks on the LogOut Button. It should create a new instance of LoginViewController and all the allocated memory of TabbarController should be removed.
You can create a new object of LoginVIewController and set it as a rootViewController.
let story = UIStoryboard(name: "Main", bundle:nil)
let vc = story.instantiateViewController(withIdentifier: "ViewController") as! ViewController
UIApplication.shared.windows.first?.rootViewController = vc
UIApplication.shared.windows.first?.makeKeyAndVisible()