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?
Rodney
was that the only line in the program you ran that exhausted available memory? how long is "eventually"?
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.
Rodney
Do some logging. Is the system calling your update function repeatedly and each one is running forever, causing a pile-up of funtion calls?
This happens to me too anytime I try to use a while loop :(
This happened to me too recently using a "while". I'm not sure what I'm doing wrong.
EDIT: Now the same code suddenly doesn't cause "out of memory". Weird!
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.
how do you call GC? do you do:
'''
gc()
garcage_collect()
_gc()
gc
'''
whitch one?
[Please log in to post a comment]