Skip to content

Instantly share code, notes, and snippets.

@0xGGGGG
Created January 7, 2012 19:51
Show Gist options
  • Save 0xGGGGG/1575799 to your computer and use it in GitHub Desktop.
Save 0xGGGGG/1575799 to your computer and use it in GitHub Desktop.
for memory screening
-- assigning nil to object is not enough. You should also call remove.
display.remove( displayObject )
displayObject = nil
timerStash = {}
transitionStash = {}
function cancelAllTimers()
local k, v
for k,v in pairs(timerStash) do
timer.cancel( v )
v = nil; k = nil
end
timerStash = nil
timerStash = {}
end
--
function cancelAllTransitions()
local k, v
for k,v in pairs(transitionStash) do
transition.cancel( v )
v = nil; k = nil
end
transitionStash = nil
transitionStash = {}
end
-- place it at the and of your main.lua for screening memory leaks
local monitorMem = function()
collectgarbage()
print( "MemUsage: " .. collectgarbage("count") )
local textMem = system.getInfo( "textureMemoryUsed" ) / 1000000
print( "TexMem: " .. textMem )
end
Runtime:addEventListener( "enterFrame", monitorMem )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment