corona icon indicating copy to clipboard operation
corona copied to clipboard

Incorrect memory reporting

Open marksolar2d opened this issue 3 years ago • 2 comments

The memory reporting in Solar is incorrect.

local function loadImages()
  for i = 1, 1000 do
    local bg = display.newImage("logo.png" )
    bg:translate(math.random(0, 960), math.random(0, 540))
  end
  print("Lua="..math.floor(collectgarbage("count")/1024).."MB, Texture="..math.floor(system.getInfo("textureMemoryUsed")/1048576).."MB"..", display objects="..display.currentStage.numChildren)
end

timer.performWithDelay( 50, loadImages, 100 )

After 100k images have been displayed sim reports around 20MB total memory being used but Windows reports memory load has increased 300MB.

marksolar2d avatar Nov 25 '21 16:11 marksolar2d

Lua only knows about its own allocations. You're seeing it report the display objects' Lua-side tables, proxies, etc. but there's more heavyweight state on the native side, allocated with malloc() or new.

ggcrunchy avatar Nov 26 '21 07:11 ggcrunchy

I figured that much. But, it is very misleading. Adding thousands of the same object "seems" to be quite cheap but actually it is very costly!

I am sure it is known the native side cost for display objects so this value could be either added to the Lua value or reported as an additional value?

marksolar2d avatar Nov 26 '21 11:11 marksolar2d