Log In  

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:


The question is...why?


P#38459 2017-03-20 14:14 ( Edited 2018-02-01 22:49)

was that the only line in the program you ran that exhausted available memory? how long is "eventually"?

P#38466 2017-03-20 18:01 ( Edited 2017-03-20 22:01)

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.


P#38468 2017-03-20 18:14 ( Edited 2017-03-20 22:14)

Do some logging. Is the system calling your update function repeatedly and each one is running forever, causing a pile-up of funtion calls?

P#38492 2017-03-21 00:15 ( Edited 2017-03-21 04:15)

This happens to me too anytime I try to use a while loop :(

P#38501 2017-03-21 06:49 ( Edited 2017-03-21 10:49)

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!

P#48849 2018-02-01 16:28 ( Edited 2018-02-01 21:51)

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.

P#48852 2018-02-01 17:49 ( Edited 2018-02-01 22:50)

how do you call GC? do you do:
whitch one?

P#65258 2019-06-18 16:56

you don’t - this is not exposed to pico user code.

P#65259 2019-06-18 17:25

[Please log in to post a comment]