Game crashes after 20 min: "Low Memory"
by Jason Oda · in iTorque 2D · 06/23/2009 (1:08 pm) · 23 replies
I have a game that crashes after 20 minutes.
The crash log is reporting it as "Low Memory"
I have lots and lots of things that I load onto the stage via "new t2dStaticSprite()" and then use safeDelete() to get rid of. Could this be part of the problem? The game works beautifully besides this.
I know there's advice out there for TGB, but not much having to do with the iTGB that's helpful.
This is my crash log:
Incident Identifier: A70D8A03-B90D-42EF-AFD1-814E497E4C11
CrashReporter Key: d7b20801b9b4a02a5e93eb055f4c1cd02084c11b
OS Version: iPhone OS 3.0 (7A341)
Date: 2009-06-23 15:13:15 -0400
Free pages: 372
Wired pages: 8956
Purgeable pages: 0
Largest process: Kitty
Processes
Name UUID Count resident pages
Kitty <fa284be2297f041d94b9c8f55e1b608a> 17009 (jettisoned) (active)
MobilePhone <9517d3db1b487371c5a64e41bfd19eda> 1068 (jettisoned)
notifyd <69e04d13344f1c006227422dbf18dde8> 83
BTServer <3ae1c6fbcb29741b4a609b02f3c5a127> 268
CommCenter <3bb4f68851d96e651f3e637a13c5a50e> 484
SpringBoard <e0166bb2d42cbc489ace07849c959088> 1817 (active)
accessoryd <0a9234886eabf7a79e1cb822a7d2af81> 171
configd <2950435c092830011e402b4ac8ea86fe> 165
configd <2950435c092830011e402b4ac8ea86fe> 369
fairplayd <ec3c2c10efbb2e7a7b9d7130ecb1e2c6> 141
mDNSResponder <21273afce237d1ff8e79ab819a130e3c> 159
mediaserverd <cc588f963f30bd34296bf8beeb803f8a> 539
lockdownd <374e220ffb0f06ac0f7aa024a979e31f> 366
syslogd <4eae063fb35192e82cf5c47df1063443> 85
launchd <09ab79ab1b390e1fee1309f58948f17c> 101
**End**
Thanks,
Jason
The crash log is reporting it as "Low Memory"
I have lots and lots of things that I load onto the stage via "new t2dStaticSprite()" and then use safeDelete() to get rid of. Could this be part of the problem? The game works beautifully besides this.
I know there's advice out there for TGB, but not much having to do with the iTGB that's helpful.
This is my crash log:
Incident Identifier: A70D8A03-B90D-42EF-AFD1-814E497E4C11
CrashReporter Key: d7b20801b9b4a02a5e93eb055f4c1cd02084c11b
OS Version: iPhone OS 3.0 (7A341)
Date: 2009-06-23 15:13:15 -0400
Free pages: 372
Wired pages: 8956
Purgeable pages: 0
Largest process: Kitty
Processes
Name UUID Count resident pages
Kitty <fa284be2297f041d94b9c8f55e1b608a> 17009 (jettisoned) (active)
MobilePhone <9517d3db1b487371c5a64e41bfd19eda> 1068 (jettisoned)
notifyd <69e04d13344f1c006227422dbf18dde8> 83
BTServer <3ae1c6fbcb29741b4a609b02f3c5a127> 268
CommCenter <3bb4f68851d96e651f3e637a13c5a50e> 484
SpringBoard <e0166bb2d42cbc489ace07849c959088> 1817 (active)
accessoryd <0a9234886eabf7a79e1cb822a7d2af81> 171
configd <2950435c092830011e402b4ac8ea86fe> 165
configd <2950435c092830011e402b4ac8ea86fe> 369
fairplayd <ec3c2c10efbb2e7a7b9d7130ecb1e2c6> 141
mDNSResponder <21273afce237d1ff8e79ab819a130e3c> 159
mediaserverd <cc588f963f30bd34296bf8beeb803f8a> 539
lockdownd <374e220ffb0f06ac0f7aa024a979e31f> 366
syslogd <4eae063fb35192e82cf5c47df1063443> 85
launchd <09ab79ab1b390e1fee1309f58948f17c> 101
**End**
Thanks,
Jason
About the author
#2
06/23/2009 (1:39 pm)
I started to play around with the optimization settings (see my other thread regarding preprocessor flags and disabling the Torque Memory Manager) and mine stopped crashing, until I added more stuff in there. Looks like I'm back to the drawing board.
#3
"When I build my project in iTGB, should I be choosing any of the particular optimizations, such as Scripts, or Full?"
1. Where do find these options? In ITGB? Can you direct me to exactly where and how to change these options? I'm not seeing them anywhere. Did this help you in the end?
2. I never got any of my games to work out side of the iTGB Target (as opposed to iTIG_Optimize, iTGB_Script, iTGB_Script_Optimize)...did this make a difference to you as far as crashing is concerned?
3. Also, does just adding that missing R on "TORQUE_DISABLE_MEMORY_MANAGE" cause your game to crash less?
My game is somewhat simple in nature (probably not as complicated as yours), and like I said I'm only ever getting crashes after about 20 minutes (which isn't bad). I just want my game to be the best I can be before I hand it over.
Thanks
06/23/2009 (2:35 pm)
Hey Raphael, thanks. Question, you said in the past:"When I build my project in iTGB, should I be choosing any of the particular optimizations, such as Scripts, or Full?"
1. Where do find these options? In ITGB? Can you direct me to exactly where and how to change these options? I'm not seeing them anywhere. Did this help you in the end?
2. I never got any of my games to work out side of the iTGB Target (as opposed to iTIG_Optimize, iTGB_Script, iTGB_Script_Optimize)...did this make a difference to you as far as crashing is concerned?
3. Also, does just adding that missing R on "TORQUE_DISABLE_MEMORY_MANAGE" cause your game to crash less?
My game is somewhat simple in nature (probably not as complicated as yours), and like I said I'm only ever getting crashes after about 20 minutes (which isn't bad). I just want my game to be the best I can be before I hand it over.
Thanks
#4
06/23/2009 (9:04 pm)
Well I got my game to run on iTGB_Optimize and added that R...but it still crashes randomly after 20 minutes due to low memory. I'm still not sure what you're referring to in #1 mentioned above. Anybody else got any stability tricks? I tried the leaks thing, but have no idea what the hell is going on when I'm running it.
#5
The game works fine in the iPod (2 gen 3.0) and after 20/30 minutes it randomly quits without any warnings.
The game is basically a single level that changes its variables settings when a "level" is cleared and stablish new values to the same variables. Lots of animated sprites are created (up to 70) and deleted using safeDelete when needed. Also, lots of Sim Sets are created over time.
What can be done to prevent this problem?
Thanks
Mike
07/12/2009 (6:41 pm)
I´m running in the same problem also :(The game works fine in the iPod (2 gen 3.0) and after 20/30 minutes it randomly quits without any warnings.
The game is basically a single level that changes its variables settings when a "level" is cleared and stablish new values to the same variables. Lots of animated sprites are created (up to 70) and deleted using safeDelete when needed. Also, lots of Sim Sets are created over time.
What can be done to prevent this problem?
Thanks
Mike
#6
that will give you knowledge of what might be causing it.
07/12/2009 (10:24 pm)
use the memory instrument to see whats going on and if something is leaking memory.that will give you knowledge of what might be causing it.
#7
I don't know if your application is using a similar setup where your staying in one level for longer than 20min but if so I think it is a strange coincidence that there are three of us with the same issue. I will be looking into this tomorrow with the XCode's test and see if there is anything I can find. Please post what resolves your problems as it might help others.
-Ecliptic
07/13/2009 (9:21 am)
I am having this problem also. I find it kind of funny that we all have the same time frame. If my app is running for 20 min it will crash. Now my app is very optimized and only uses a handfull of scripts right now so I am thinking it might be a small leak somewhere in my source code dealing with the levels. I say this because my game loads a level and turns it into a puzzle to solve, thus staying in the same level the whole time. If I wait around 19 min and go back to the main menu, which is a different level file since I am not using the gui's, the game will not crash.I don't know if your application is using a similar setup where your staying in one level for longer than 20min but if so I think it is a strange coincidence that there are three of us with the same issue. I will be looking into this tomorrow with the XCode's test and see if there is anything I can find. Please post what resolves your problems as it might help others.
-Ecliptic
#8
Of course, not everyone has a 3GS, so it would be best to find that obscure line that reads "if ($gameTimerInMinutes > 20) crash();"
07/13/2009 (9:34 am)
As soon as I bumped up to the 3GS, I never experienced a game crash in my game. With the 3G and iPhone, it was almost inevitable, especially when it came to loading levels. The 3GS does has 256MB where the older generations have 128MB, so that's a big factor.Of course, not everyone has a 3GS, so it would be best to find that obscure line that reads "if ($gameTimerInMinutes > 20) crash();"
#9
I did experience the 20-min crash when I did a pure script-based game. After I recoded to primarily C++, the problem disappeared. I could never find it in the original all-script game!
07/13/2009 (9:35 am)
I don't think the leak is in creating new sprites. I've got a game I'm currently working on that creates probably 80 in a game without a leak. I did experience the 20-min crash when I did a pure script-based game. After I recoded to primarily C++, the problem disappeared. I could never find it in the original all-script game!
#10
The game has 3 major levels, one for each game mode, but the crash occurs no matter if you´re playing in a single level or not. I´ve been testing the whole morning and it happen after the 20-22 minutes even if I quit a game mode (a level) and go to play another (another level).
@Chris,
Sadly I can´t code C++ and I´m using a large script (16000 lines) for the primary game... May it help if I split the script in several smaller scripts?
Cheers
Mike
07/13/2009 (2:13 pm)
@Ecliptic,The game has 3 major levels, one for each game mode, but the crash occurs no matter if you´re playing in a single level or not. I´ve been testing the whole morning and it happen after the 20-22 minutes even if I quit a game mode (a level) and go to play another (another level).
@Chris,
Sadly I can´t code C++ and I´m using a large script (16000 lines) for the primary game... May it help if I split the script in several smaller scripts?
Cheers
Mike
#11
You will likely have to convert part of it to C++
Out of all posting here: how many of you tested it without the script optimization? Just to rule out that the new script compilation isn't the root of the problem.
07/13/2009 (2:25 pm)
No not reallyYou will likely have to convert part of it to C++
Out of all posting here: how many of you tested it without the script optimization? Just to rule out that the new script compilation isn't the root of the problem.
#12
Sure enough, as I said with the new version, the conversion to mostly C++ seemed to totally fix it.
07/13/2009 (3:06 pm)
Optimize vs non-optimize did show a slight difference. The latter had a tiny leak that wasn't much of a threat. But neither stopped the 20-min crash (aka the big leak, ie 1 MB a minute). I tried many, many things... object recycling, schedule handling, etc... but I never found the leak. I figure it *had* to be the large amount of script.Sure enough, as I said with the new version, the conversion to mostly C++ seemed to totally fix it.
#13
The only optimization the game has is the setUsesPhysics() set to true for several objects.
I have discovered that time is not the cause of my game crashing since it has now 40 minutes and is working well. But I´m not playing it, I run it and play up to level 3 and then I leave it alone. The problem seems to be the fact that maybe memory is not being freed after an object was deleted (using safedete())???
I´m asking this because no matter the time I play the game, it always crashes after level 10 or more. Which means in the game that at least 600 objects were created and deleted... could that be? if so, somebody knows how to freed memory after objects deletion?
Thanks
Mike
07/13/2009 (3:23 pm)
@Marc,The only optimization the game has is the setUsesPhysics() set to true for several objects.
I have discovered that time is not the cause of my game crashing since it has now 40 minutes and is working well. But I´m not playing it, I run it and play up to level 3 and then I leave it alone. The problem seems to be the fact that maybe memory is not being freed after an object was deleted (using safedete())???
I´m asking this because no matter the time I play the game, it always crashes after level 10 or more. Which means in the game that at least 600 objects were created and deleted... could that be? if so, somebody knows how to freed memory after objects deletion?
Thanks
Mike
#14
So my question is: what can I do to ensure that memory is freed after objects are deleted? is this possible or is this an iTGB bug?
Also, need to ask: if a SimSet is not deleted, but the objects contained on it are, the used memory is down? It will be healthy to delete any SimSet when unuseful to freed memory?
Thanks
Mike
07/13/2009 (3:50 pm)
Yes, it seems that the problem (in this case) has to be with the memory not being freed after objects are deleted. Game has been running for 65 minutes.So my question is: what can I do to ensure that memory is freed after objects are deleted? is this possible or is this an iTGB bug?
Also, need to ask: if a SimSet is not deleted, but the objects contained on it are, the used memory is down? It will be healthy to delete any SimSet when unuseful to freed memory?
Thanks
Mike
#15
the new compiler (-> with script change compiler flag enabled) was introduced post iTGB release and did have nowhere as much testing as the original torque script that has a good 10 years of testing now.
07/13/2009 (4:13 pm)
I'm talking about the script change vs not script change compiler flags.the new compiler (-> with script change compiler flag enabled) was introduced post iTGB release and did have nowhere as much testing as the original torque script that has a good 10 years of testing now.
#16
-Ecliptic
07/21/2009 (9:31 am)
I found my issue was dealing with sprite animations but I don't know why just yet. I cleared up some of the leak (about 50% of it) but surprisenly enough it did not increase the duration you could play with out it recieving the error.... This is going to be fun. :)-Ecliptic
#17
As a test, I've decided to isolate the scenegraph from all guis and just loadSceneGraph and clear and delete scenegraph multiple times to see what happens. as suspected memory is getting piled up every time you do it. I doubt if that was the case with 1.1. my previous game was hardly crashing and definitely going over 20 min and multiple levels.
07/21/2009 (3:57 pm)
same problem here. Also deleting every gui and scenengraph as soon as I'm done , but it doesn't help.As a test, I've decided to isolate the scenegraph from all guis and just loadSceneGraph and clear and delete scenegraph multiple times to see what happens. as suspected memory is getting piled up every time you do it. I doubt if that was the case with 1.1. my previous game was hardly crashing and definitely going over 20 min and multiple levels.
#18
Will be fixed in 1.3... and when?
Thanks,
Mike
07/22/2009 (4:21 pm)
Have somebody fixed this problem? Will be fixed in 1.3... and when?
Thanks,
Mike
#19
This will tell you when and what is leaking.
All I've seen posted in this thread so far are blind guesses into the dark that won't get you a single step closer to the solution of the problem.
07/22/2009 (4:29 pm)
Start the game with the Memory Instrument on the iPhoneThis will tell you when and what is leaking.
All I've seen posted in this thread so far are blind guesses into the dark that won't get you a single step closer to the solution of the problem.
#20
Thanks. But where is the memory Instrument and how should I use it?
Mike
07/22/2009 (4:34 pm)
@Marc,Thanks. But where is the memory Instrument and how should I use it?
Mike
Torque 3D Owner Mat Valadez
Default Studio Name