After several days of debugging and trial and error, I’m stuck and need some help.
Here is the case:
I’m developing a game for iPhone using Unity iPhone Basic 1.7.0f1 (38208). The game is pretty much done, but I do have one major problem left to fix. Otherwise the game will be rejected, that’s for sure. The game consists of 4 scenes: an intro scene, main menu scene, loading scene and the game scene. The game runs smoothly most of time on my 3Gs but I do experience ‘hiccups’ now and then. Nothing seriously and it haven’t crashed yet, but the results from Apple’s Instruments worries me. In this thread I’ve tried to gather as much data about the game as possible, hoping you guys can point me in the right direction. What I basically don’t understand is why the memory does not get flushed when shifting scenes.
And now to all the data, thank you for your help.
When main menu is the first scene the reel mem shows:
30MB
When game scene is the first scene
38MB
However when I start the main menu as the first scene and go to the game scene the memory usage goes to 56 MB and the game starts to run with an unstable frame rate, it isn’t crashing though.
Using instruments after going back and forth between the main menu and the game scene 279 leaks (8 KB) leaks were detected.
Using the detect leaks script I get following results:
When starting in main menu:
4524
Textures 191
AudioClips 29
Meshes 187
Materials 32
GameObjects 319
Components 1271
When starting the game scene only:
All 4708
Textures 191
AudioClips 29
Meshes 242
Materials 32
GameObjects 319
Components 1390
When going from main menu to game scene:
All 4742
Textures 191
AudioClips 29
Meshes 244
Materials 33
GameObjects 324
Components 1405
When shifting between main menu and game scene 3 times:
All 4757
Textures 191
AudioClips 29
Meshes 245
Materials 33
GameObjects 324
Components 1407
My game includes:
11 textures
14 materials
29 audio clips (one is background music in m4a format around 5MB)
I don’t get why the format is shown as ogg in the Unity Editor when I used iTunes to create the m4a file from an mp3. However it is marked as iPhone Background music, so I guess there is nothing wrong here.
I do have one game object that has a DontDestroyOnLoad script and one static class, none of them holds reference to other gameobjects, but multiple gameobjects holds a reference for them.
Thank you for helping me out.