Created
January 7, 2012 19:51
-
-
Save 0xGGGGG/1575799 to your computer and use it in GitHub Desktop.
for memory screening
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- assigning nil to object is not enough. You should also call remove. | |
display.remove( displayObject ) | |
displayObject = nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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