Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect memory reporting #308

Open
marksolar2d opened this issue Nov 25, 2021 · 2 comments
Open

Incorrect memory reporting #308

marksolar2d opened this issue Nov 25, 2021 · 2 comments

Comments

@marksolar2d
Copy link

marksolar2d commented Nov 25, 2021

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.

@ggcrunchy
Copy link
Contributor

ggcrunchy commented Nov 26, 2021

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.

@marksolar2d
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants