Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any memory leak (or over-instantiation of objects) when using iOS Storyboard Seque "Model" or "Push" style?

Let's say I'm developing a simple iPhone app with two screens: Login and Register screens. Within the Login screen, it has the "Register" button which takes to the Register screen. Likewise, within the Register screen, it has the "Login" button which takes to the Login screen. All is implemented using iOS Storyboard Segue "Modal" style.

The question is: does keep adding a new view to a stack everytime a view controller is presented by a segue "Modal" style? So, if I repeatly switch between the Login and Register screens, will it instantiates new objects everytime and keeps accumulating with an internal array container (ie. stack)?

Further, if I change the style to "push", how will the situation be like to the similar question? Doesn't "push" keeps adding new view objects to the top everytime it is "pushed"?

like image 613
ikevin8me Avatar asked Dec 02 '25 14:12

ikevin8me


2 Answers

@trapper is absolutely correct. You segues will stack them up, but it won't leak as long as you dismiss your "modal" with dismissViewControllerAnimated:completion: or pop your pushed view controller with popViewControllerAnimated:. If you erroneously have a segue from your login/register screen back to the main view, then that memory won't be released (which isn't technically a leak, but it's wrong and you won't release the memory).

like image 169
Rob Avatar answered Dec 04 '25 08:12

Rob


Yes it will keep stacking them up either way.

Just to clarify though, it wont cause any leaks.

like image 42
trapper Avatar answered Dec 04 '25 08:12

trapper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!