Things that makes GS go Boom!
Just thought to share some results of my game stress testing process. What I did, I cranked up some of the game attributes (like speed) to very high levels trying to get the game to crash in order to see what are my memory/performance margin.
Please note: The goal of the process was to get the game to crash
Few notes:
1. I do not use spawn/destroy or any of the reset behaviors
2. Pre load is always off
3. Moving is extremely selective
4. My scenes are usually large to avoid load times when I can
5. Game is 24.8mb (in GS, but 48mb as an Ad Hoc) with 10 scenes and 168 actors, most actors split between 2 scenes
Results
1. The game will always crash when GS will try to allocate 50mb to the Game Engine memory. You might see the crash as 47mb, 48mb or 49mb (highest that I have seen was 49.1mb), but you will not get anything higher than 50mb.
2. I did not manage to get the game to crash due to other memory settings, 'Other' got as high as 121.9mb with 'Total' of 186.4mb without any impact of performance or stability (that was shortly before Game Engine cause another crash)
3. There seems to be some kind of garbage collector or something else that cleans the Game Engine memory every 40-60 seconds. To get it to crash I had to 'outrun' that process.
4. In one process of my game, Game Engine memory grow by 0.9mb per second
5. Gamesalad Viewer is consistent with an Ad Hoc build, I tested both side by side and the crashes were consistent. I also tested GS viewer on the device and on the simulator with consistent results
Finding
I tried to find which element was causing Game Engine memory to grow so rapidly (0.9mb per second):
1. I have a frequently changing images with 'Change Attribute' - I was happy to learn that it was not the cause
2. I dramatically optimized the code in that area - marginal improvements, basically got me down to ~0.8mb per second...
3. I had a sound effect that was repeating itself with 'Run to Completion' on - this was the one item that cause most of the issues, while the sound effect itself is about 10k, 1 second long and repeats itself 2-3 times every second (in normal game speed that would be around 1 per second), it caused the Game Engine memory to grow by about 0.6mb per second. Turning off 'Run to Completion' reduced that to ~0.1mb per second. This was sufficient for the 'garbage collector' to outrun my ability to test (managed to get to 41mb before it dropped it to 31mb). I was actually surprised that playing a 10k sound file cause a very dramatic impact.
If you ask why did I do it, the answer is simple. Now that I managed to optimize my game on what is considered to be extreme conditions, I know that it will likely to be stable when people will use it. It is also a good method to force you to find new ways to optimize your code farther.
Hope someone will find it useful.
Cheers,
GR
PS.
I didn't want to bump a very old thread by TSB (http://forums.gamesalad.com/discussion/767/game-engine-hit-45mb), but it seems that the Game Engine memory limit was noticed before by others.
Please note: The goal of the process was to get the game to crash
Few notes:
1. I do not use spawn/destroy or any of the reset behaviors
2. Pre load is always off
3. Moving is extremely selective
4. My scenes are usually large to avoid load times when I can
5. Game is 24.8mb (in GS, but 48mb as an Ad Hoc) with 10 scenes and 168 actors, most actors split between 2 scenes
Results
1. The game will always crash when GS will try to allocate 50mb to the Game Engine memory. You might see the crash as 47mb, 48mb or 49mb (highest that I have seen was 49.1mb), but you will not get anything higher than 50mb.
2. I did not manage to get the game to crash due to other memory settings, 'Other' got as high as 121.9mb with 'Total' of 186.4mb without any impact of performance or stability (that was shortly before Game Engine cause another crash)
3. There seems to be some kind of garbage collector or something else that cleans the Game Engine memory every 40-60 seconds. To get it to crash I had to 'outrun' that process.
4. In one process of my game, Game Engine memory grow by 0.9mb per second
5. Gamesalad Viewer is consistent with an Ad Hoc build, I tested both side by side and the crashes were consistent. I also tested GS viewer on the device and on the simulator with consistent results
Finding
I tried to find which element was causing Game Engine memory to grow so rapidly (0.9mb per second):
1. I have a frequently changing images with 'Change Attribute' - I was happy to learn that it was not the cause
2. I dramatically optimized the code in that area - marginal improvements, basically got me down to ~0.8mb per second...
3. I had a sound effect that was repeating itself with 'Run to Completion' on - this was the one item that cause most of the issues, while the sound effect itself is about 10k, 1 second long and repeats itself 2-3 times every second (in normal game speed that would be around 1 per second), it caused the Game Engine memory to grow by about 0.6mb per second. Turning off 'Run to Completion' reduced that to ~0.1mb per second. This was sufficient for the 'garbage collector' to outrun my ability to test (managed to get to 41mb before it dropped it to 31mb). I was actually surprised that playing a 10k sound file cause a very dramatic impact.
If you ask why did I do it, the answer is simple. Now that I managed to optimize my game on what is considered to be extreme conditions, I know that it will likely to be stable when people will use it. It is also a good method to force you to find new ways to optimize your code farther.
Hope someone will find it useful.
Cheers,
GR
PS.
I didn't want to bump a very old thread by TSB (http://forums.gamesalad.com/discussion/767/game-engine-hit-45mb), but it seems that the Game Engine memory limit was noticed before by others.
Comments
Lump Apps and My Assets
---
Benjamin
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User