Is there a way to tell how much memory your program is using, while it's running?

The reason is I’m using some big texture images for a mesh, and I wanted to find out if the images remain in memory after they’ve been used to texture the mesh, ie whether it makes a difference what size images you use to texture a particular mesh.

But knowing how much memory you’re using is useful anyway.

@Ignatz@Jmv38 has a memory monitor in his Windows library. I believe he uses:

local kb = gcinfo()

Thanks!

Hi! I have always wondered if this command really measures the memory used by images and meshes. Please let us know if you find out.

I ran it on an empty app and it showed about 180, then on my app with big mesh images, and it was up to 400. Is that 400mb?

gcinfo is a Lua function, so I’m not sure it picks up the total memory used by Codea, even if Codea uses Lua to store everything.

The value returned is in KB

Does anyone know what size is going to cause a problem with memory limits?

A non-answer could be: it depends on the other apps opened…
I know i have constantly memory problems if i dont use collectgarbage() at adequate places…
So assuming all apps are closed, and you use collectgarbage a lot, then … I dont know.
But the available memory in my ipad1 is generally 100Mo, a fullscreen color image is 1024x768x3 so about 2.4Mo, so the absolute limit would be 40 images? The real limit should surely be 1/2 or 1/3 of that.

Interesting. Without garbage collection, I am currently at 270 plus. When I do garbage collection while setting up my mesh, it drops to 175, but then climbs steadily back to 250 plus. If I put periodic garbage collection into draw, it drops down to 175 each time, then climbs slowly again until I collect it again.

fps class

-- fps

fps = class()

function fps:init()
    parameter.watch("fps")
    parameter.watch("mem")
end

function fps:update()
    fps = math.ceil(string.format("%.2f", 1/DeltaTime))
    
    collectgarbage()
    collectgarbage()
    collectgarbage()
    mem = collectgarbage("count", 2) --in KB
end

use in main

function setup()
    monitor = fps()
end

function draw()
    monitor:update()
end