Posted about this in the playdate squad discord, didn't find any clear answers so asking here. What do people use to manage memory consumption on device without the use of simulator? I want to be able to log system memory (% of total, preferably) at key points in my game in order to profile how optimization changes affect memory consumption, as well as having a way for QA to view memory usage in development builds (surely this must be possible... for context, the game in question is pushing up against the limits of 16MB pretty hard so I need to squeeze everything I can out of it)
There are 2 ways I know: device info in the simulator, and collectgarbage("count"). The former works great, but requires a tethered playdate with a human paying attention to it, and isn't useful for my case.
While there are many posts on this forum detailing how to use the latter to view available memory.. it doesn't seem to actually work? collectgarbage("count"), as far as I can tell, does not return anything relating to system memory usage but rather Lua memory. I tested it with a short Lua program:
import "CoreLibs/graphics"
function playdate.update()
playdate.graphics.clear(playdate.graphics.kColorWhite)
playdate.graphics.drawText(collectgarbage("count") .. " KB", 100, 100)
if(playdate.buttonJustPressed(playdate.kButtonA)) then
mygarbage = playdate.graphics.image.new(1024, 1024, playdate.graphics.kColorBlack)
end
if(playdate.buttonJustPressed(playdate.kButtonB)) then
mygarbage = nil
end
end
When pressing A, the above code does not show a substantial increase in memory consumption, but the device info screen shows a whopping 125KB increase (which makes complete sense).
So, how do y'all get memory consumption of the device at runtime?