Inconsistent crashing

Hi,
I created a multi-level game which crashes inconsistently on two of the levels. I'm trying to narrow down this problem but since it's very inconsistent and only happens on the device, it's difficult to track it down. I tried to comply with all of the good practices of removing objects and event listeners when moving from one level to another, using local variables, etc...

Question: I have a lot of timer.performWithDelay methods that trigger various movieclip animations, some of them run on infinite loops. Should I cancel all of these timers after each level is completed or do they get cleaned up by the system automatically. This is the only issue that I'm suspecting might be giving me troubles. BTW, I don't get any errors in the terminal.

Example of a crash: After completing a level, a cut scene is presented. Just a few graphics that are animated with transitions and movieclips. There are no touch event listeners added to this scene yet, when the screen is tapped it crashes the app. Sometimes it takes just one tap sometimes it takes multiple taps, and sometimes it doesn't crash at all. It's very strange and I'm wondering if there is an issue between timer.performWithDelay and tapping that makes the app crash.

Any advise or direction would be greatly appreciated, thank you in advance.

I think it's a good idea to cancel all the timers after a level is complete.

Take a look at http://blog.anscamobile.com/2011/08/corona-sdk-memory-leak-prevention-101/

In the "Timers and Trasitions" section it shows how to add all of these to a table as they are created and then call a cancelAllTimers() function when you want to cancel all of them.

As elbowroomapps said, yes - cancel any timers or transitions that are going on when you change levels! They aren't automatically cleaned up and are almost certainly the cause of your headaches.

Peach :)

Thank you for the link and advise. It looks like it's the timers and transitions in my case.

views:1441 update:2011/9/26 15:43:22
corona forums © 2003-2011