Repeated calls to image() and sprite() crash Codea

It seems the following crashes Codea after around 120 iterations. I guess the relevant GL resource leaks and is exhausted. I was hoping I could be lazy but it seems this isn’t handled gracefully. Oh, on looking at the docs it seems there isn’t a free for the codeimage types so even if went to the trouble to release them I can’t?

function draw()
local i=image(400,400)

PS Loving Codea!

Oh, now I get it - all the image() calls should be one off during setup. This is pretty reasonable as there is a lot of memory involved and you could always do your own management of the images, I suppose. (Obviously the crash is bad though).

The crash is bad. It looks like it might be our bug – those local images you create in the draw loop should be garbage collected but it looks like they are not.

You are right that you should probably create those in setup() as a once-off, though.

@Dylan has looked into this and it’s because Lua’s garbage collector only runs every few seconds, yet you are allocating hundreds of images per-second.

So we’ll find a way to fix this issue, but the bug fix won’t be available until after version 1.3. I think for now if you need this sort of functionality you could try manually force a garbage collection with the collectgarbage() function.

Thanks, it is not huge for me, just wanted to report it. Looking forward to 1.3!