Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Memory leaks — Gideros Forum

Memory leaks

Tom2012Tom2012 Guru
edited October 2012 in Suggestions & requests
I'm using
local monitorMem = function()
    collectgarbage()
    print( "\nMemUsage: " .. collectgarbage("count") )
end
stage:addEventListener(Event.ENTER_FRAME, monitorMem)

To track memory leaks. I'm spawning a box2d sprite, removing it's physics fixture and body, then removing the sprite from the scene. But my memory usage slowly ticks up and up as each sprite is added and removed.

What are some other things that could cause this?

I think I'm removing the timers and event listeners correctly...

Thanks

Comments

  • There was something about that collectgarbage does not free the memory instantly, it takes some time. Or you could call collectgarbage function multiple times to free memory sooner. But without seeing your code, I don't know if this is the case.
  • Tom > Do you see any differences with the following :
    local floor = math.floor
    local monitorMem = function()
         collectgarbage()
         collectgarbage()
         collectgarbage()
         print("MemUsage: ", floor(collectgarbage("count")))
    end
    twitter@TheWindApps Artful applications : The Wind Forest. #art #japan #apps
  • Tom2012Tom2012 Guru
    edited October 2012
    Thanks for the help.

    I think I have found the problem - each sprite had a timer attached. Adding timer:stop(); seems to have fixed things.

    Thanks again.

    Likes: atilim

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.