Granted, I'm a novice to both Lua and PICO-8, but when I was able to get down to the core of what was throwing the out of memory error (after a few hours), I was astounded.
This one line will eventually exhaust all memory:
WHILE TRUE DO END
The question is...why?
No, it's several hundred lines long - put that at the end to 'spin' it so I could observe the display layout and make sure things are as I want (I'm working on a Telengard port/clone).
Even running only that single line from the interpreter after a fresh reboot, it will still run out of memory after a few hours.
PICO-8 actually seems to be able to interrupt your infinite loop to update the display periodically. I suspect that the code which runs during that interrupt generates a few new lua values.
Thing is, Lua values are garbage collected. They are never directly destroyed, only removed when doing garbage collection, which basically checks to see what's still "visible" from the point of view of the global space. If nothing references a value/object anymore, it's deallocated. (I think Lua does this with a mark-and-sweep algorithm...?)
Garbage collection in Lua only happens when requested, though. It's quite possible that zep isn't requesting a GC when he interrupts to update the display. If so, each time he does, he adds a little bit to the app's memory heap in the form of a few new Lua values, and eventually he runs out of heap space and you go out-of-memory.
@zep - So, like, you ought to call GC when you interrupt, at least if it hasn't been done in a long time.
[Please log in to post a comment]