Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

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

edited January 2012 in Bugs Posts: 29

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)
sprite(i,0,0)
end

PS Loving Codea!

Comments

  • Posts: 29

    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).

  • SimeonSimeon Admin Mod
    Posts: 5,759

    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.

  • SimeonSimeon Admin Mod
    Posts: 5,759

    @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.

  • Posts: 29

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

Sign In or Register to comment.