The Problem
I'm currently building an iPad game using SpriteKit. The gameplay is driven by sound provided by EZAudio. After running the Instrumentation tools to profile my app, I noticed that whenever the
GameViewController
is shown memory allocation jumps up. When I repeatedly show the screen (5+ times) it crashes the app. My project uses ARC.
Navigation
The navigation consists of 4 ViewControllers
:
- MenuViewController: This shows the menu
- CharacterSelectionViewController: It lets you a pick a character to use
- GameViewController: This lets you play a game with the player chosen
- ScoreViewController: It shows you the score you achieved in the game
1 - MenuViewController
From here you can navigate to CharacterSelectionViewController
via a Show (e.g. Push
) segue.
2 - CharacterSelectionViewController
You can navigate to GameViewController
via a Show (e.g. Push)
segue. There is also a back button that goes back to MenuViewController
with the following code:
[self.navigationController popViewControllerAnimated:YES];
3 - GameViewController
- It first shows a 5 second countdown (using
NSTimer
) - The game starts with the character chosen in
CharacterSelectionViewController
- The game can be paused, allowing you to quit and go back to
MenuViewController
via a manualShow Detail (e.g. Replace)
segue. - When the game ends, a manual
Show (e.g. Push)
segue is called that navigates to theScoreViewController
.
It's view hierarchy consists of three sets of view - one for the countdown, one for the pause menu and one for the game. These are subsequently shown/hidden. See the view hierarchy below:
4 - ScoreViewController
This allows you to quit or restart the game. When quit it pressed it performs a Show Detail (e.g. Replace)
segue to MenuViewController
. If restart is pressed it performs an unwind
to CharacterSelectionViewController
.
Responses
Please provide answers regarding:
- How this kind of leak could occur
- Any observations you have from the allocation and leaks screenshots
Allocation
Below, you can see the increasing allocations as I cycle through the apps screens to repeatedly show the GameViewController
. I used Mark Generation
to be able to show the increase in memory allocations.
Leaks
Here you can see the memory leak that occurred. This is ordered by size.
Aucun commentaire:
Enregistrer un commentaire