Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dealloc not called on all view controllers when using unwind segues

I am designing a game with 6 view controllers.

I use modal segues to navigate forward and unwind segues to navigate back.

The game flow through the view controllers is A -> B -> C -> D -> E -> F.

When I try to unwind from F to A dealloc is only called on B and C. This means that each time the game is played the memory used is constantly increasing.

I initially thought the problem was due to something being retained causing dealloc not to be called on view controllers D and E. However, if I set the unwind segue to go from F to D dealloc is called for both F and E which would seem to rule out this as the problem.

I also have a route directly to from view controller A to F. When I unwind in this case dealloc is called on F correctly.

View controllers F and C call the same unwind action on A. I assume this isn't the cause as I have tried changing it to use unique unwind actions for each view controller.

Any thoughts on what is causing this? I have copied some of the code used below. Please let me know what other code (if any) would be helpful in resolving this. Any help would be greatly appreciated.

Unwind action as below:

- (IBAction)unwindToMainMenu:(UIStoryboardSegue *)unwindSegue
{}

Call to trigger unwind segue from view controller F to A:

[self performSegueWithIdentifier:@"ReturnToMainMenu" sender:self];
like image 865
user1980555 Avatar asked Mar 05 '26 05:03

user1980555


1 Answers

Following your description, the problem should be on D. Probably D is retained from someone else and so it is not deallocated when you go from F directly to A. Being not deallocated it continue to retains E which retains F.

So, be concentrate on D ;)

like image 125
Matteo Gobbi Avatar answered Mar 06 '26 18:03

Matteo Gobbi