No worries, thanks Josh.
Yup, I agree that there isn’t an ever-growing memory leak each frame, which would be a huge problem if there were, and surely not the first time it would’ve come up!
But what’s still a bit strange to me is that there does seem to be a permanently higher memory usage plateau after creating some display objects and then properly removing them, as if not all the memory is being reclaimed.
Here’s an I think even simpler example that illustrates what tedsdogs post was about.
[blockcode]
local sayMem = function()
collectgarbage()
print( "MemUsage: "…collectgarbage(“count”) )
end
sayMem()
local group = display.newGroup()
display.newRect(group, 0, 0, 1, 1)
group:removeSelf()
group = nil
sayMem()
[/blockcode]
When I run the above, the first memory printout is 102.779, but the second is slightly higher 103.011, even though the objects were removed. That suggests that some memory isn’t being reclaimed. (The exact numbers will probably vary depending on your machine and which device you simulate.)
If you then add a few more rectangles (i.e., copy/paste line 9 a few times), and the difference between the memory usage in the first and second printout gets even larger. The growth in the before/after difference appears to scale linearly (by about 0.12 in my case) for each new rectangle.
- Andrew [import]uid: 109711 topic_id: 36988 reply_id: 145256[/import]