I made these simple test to check for memory leaks:
Test 1
main.lua
[lua]local function memMonitor()
collectgarbage()
print(string.format(“Memory Usage: %.2f KB”, collectgarbage(“count”)))
local texMem = system.getInfo(“textureMemoryUsed”) * 0.000001
print(string.format(“Texture Memory: %.2f MB”, texMem))
end
local image
image = display.newImageRect(“image.png”, 32, 52)
image:removeSelf()
image = nil
timer.performWithDelay(1000, memMonitor, 0)[/lua]
Output:

Test 2
main.lua
[lua]local function memMonitor()
collectgarbage()
print(string.format(“Memory Usage: %.2f KB”, collectgarbage(“count”)))
local texMem = system.getInfo(“textureMemoryUsed”) * 0.000001
print(string.format(“Texture Memory: %.2f MB”, texMem))
end
local image
for i = 1, 100 do
image = display.newImageRect(“image.png”, 32, 52)
image:removeSelf()
image = nil
end
timer.performWithDelay(1000, memMonitor, 0)[/lua]
Output:

Test 3
main.lua
[lua]local function memMonitor()
collectgarbage()
print(string.format(“Memory Usage: %.2f KB”, collectgarbage(“count”)))
local texMem = system.getInfo(“textureMemoryUsed”) * 0.000001
print(string.format(“Texture Memory: %.2f MB”, texMem))
end
local image
for i = 1, 1000 do
image = display.newImageRect(“image.png”, 32, 52)
image:removeSelf()
image = nil
end
timer.performWithDelay(1000, memMonitor, 0)[/lua]
Output:

How is it possible that the memory has been increased if I removed all DisplayObjects and have set its reference to nil? [import]uid: 116181 topic_id: 34969 reply_id: 334969[/import]

