Skip to content

Instantly share code, notes, and snippets.

@cspencegists
Created November 19, 2012 17:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cspencegists/4111969 to your computer and use it in GitHub Desktop.
Save cspencegists/4111969 to your computer and use it in GitHub Desktop.
Corona SDK: Monitor Memory Usage
-- @DEBUG monitor Memory Usage
local printMemUsage = function()
local memUsed = (collectgarbage("count"))
local texUsed = system.getInfo( "textureMemoryUsed" ) / 1048576 -- Reported in Bytes
print("\n---------MEMORY USAGE INFORMATION---------")
print("System Memory: ", string.format("%.00f", memUsed), "KB")
print("Texture Memory:", string.format("%.03f", texUsed), "MB")
print("------------------------------------------\n")
end
-- Only load memory monitor if running in simulator
if (system.getInfo("environment") == "simulator") then
Runtime:addEventListener( "enterFrame", printMemUsage)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment