Screen freeze and app quits question

I have optimized the used memory for my game now but when testing on device I still encounter a problem when there is a lot of action going on in the game. The used memory stays in a save area but it seems the actions which are done in loops to aim and fire at targets is too much with a huge enemy count and the game gets slow until it starts to lag and one time it froze and then quit automatically.

I now wonder what, besides the memory usage, can cause this kind of behavior?

I will look into the enemy wave cycle code next because I think it could be to many loops running at once or something like this. Is this possible?

I also notice the device gets hot with a lot of action going on. Can the temperature alone cause such a lag and freeze and even quit the game?

if you are not doing it already, it is a good idea to use a pool of enemy objects that you reuse/recycle, instead of creating new and removing old enemies. especially useful if you have a lot going on with a lot of enemy objects.

one thing i try to keep in mind is to keep it all at a minimum. for example, no reason to run 3 different loops if I can combine the logic into a single loop, even if it requires setting a flag to achieve it. no reason to call a function each “enterFrame” if it is enough to run it on a slower timer. i like to think those small things add up.

in my current project i use widget.tableView a lot, and I discovered that instead of creating objects, add them to the row, then start to modify them…it got a lot smoother when adding them to the row after I was done modifying them.

you need to step through your code, disabling parts, running smaller segments, to find out whats hurting you the most, then come up with smart solutions. testing is everything.

there are really so many things that could be going and and things that can be done to tune it, so hard to give a definitive answer to what is causing this so thats all i got mate.

This already helps! Thank you!

if you are not doing it already, it is a good idea to use a pool of enemy objects that you reuse/recycle, instead of creating new and removing old enemies. especially useful if you have a lot going on with a lot of enemy objects.

one thing i try to keep in mind is to keep it all at a minimum. for example, no reason to run 3 different loops if I can combine the logic into a single loop, even if it requires setting a flag to achieve it. no reason to call a function each “enterFrame” if it is enough to run it on a slower timer. i like to think those small things add up.

in my current project i use widget.tableView a lot, and I discovered that instead of creating objects, add them to the row, then start to modify them…it got a lot smoother when adding them to the row after I was done modifying them.

you need to step through your code, disabling parts, running smaller segments, to find out whats hurting you the most, then come up with smart solutions. testing is everything.

there are really so many things that could be going and and things that can be done to tune it, so hard to give a definitive answer to what is causing this so thats all i got mate.

This already helps! Thank you!