How to know when a controller unload in Swift

In my iOS application I have a login page that leads to the main pages. You can navigate between these pages with a tab bar. On each of these pages you can log out and return to the login page using the dismiss function. I wanted to know if by doing this I was leaving some controllers in a vacuum without having unloaded them.

For example, if I log in, go to the second tab and log out, will the first tab be unloaded? And more broadly how does navigation with a tab bar work if it's not a stack?