What can make Codea just crash out?

When I’m running my program under Codea, sometimes, randomly, it crashes back to desktop and has to be restarted. I don’t see a red message coming up (though of course there could be one). It just goes away.

What sort of issue in my code could make that happen?


I have found if you have a lot of functions or paste big bits of code int on another project it wil just plain crash. It’s very iffy on when it wants to crash, and sometimes it just crashes for no reason! Most of the time it is just stress on the app and iPad for me, but it may be different for you. Try to make the program as efficient as possible with minimal lines ( even tho this is very hard to do)

On my iPad Air 1, I generally find Codea itself to be very stable. I would say that when the entire app crashes without warning, it is generally a memory management issue with my code, such as creating too many large objects (eg images), which can happen if you don’t destroy the object after you’ve finished with it.

@RonJeffries Add this to your code and see if memory keeps climbing.

text("KB Memory used  "..collectgarbage("count")//1,WIDTH/2,HEIGHT-100)

interesting idea on memory, dave … i’d have hoped that the app wouldn’t crash on a memory overflow but worth checking. i agree that memory seems likely but there’s no recursion (that i know of) and i checked all my push matrix pop matrix stuff.

and, of course, i can’t make it happen now. :slight_smile:

the collect goes from a bit above 1000KB down to a bit more than 400KB, even with some huge number of missiles on the screen. And never crashes, darn it … I wonder if it is something in the IDE side …

Since the memory usage is cycling between 1000KB and 400KB shows that you’re not loosing memory. I guess it’s going to take a little more detective work to figure out why you crash.

yes. i will fiddle the loop code because of the next problem but i don’t think i’m recurring, looping etc. Will continue to try to figure out what …

I think I’ve had this problem both with memory issues, eg large images, and also with bugs that misallocated or mistyped objects.

I usually try to find it by simplifying the code as much as possible, commenting chunks out, until I can isolate the cause.

Whenever mobile safari does that it’s usually in response to the app running out of memory. Normally when iOS starts to run out of memory it will emit a low memory warning event to all apps which is an indication that they should perform some cleanup.

Might be worth checking to see what other apps you have running at the time - also try exporting the app and running it under the xCode simulator that way you can inspect the device logs.

Alternatively you could try isolating bits of code to see which one causes the issue or failing that put some extra logging in that will output the print log to a file - that way when your app crashes and you restart you can see the last block of code executed.

Yes, well, if I had a consistent way to produce it, I could isolate it. Failing that I’m looking for things known to crash Codea so I can make sure I’m not doing those :slight_smile:

Seems I have the same behavior. See: https://codea.io/talk/discussion/7381/codea-runtime-quits-my-app-after-some-time#latest