Hi JB,
The image is actually cleared from the cache once it’s removed from the display, not necessarily garbage collected. You can test this easily by putting some images on the screen, watching the texture memory using the common “checkMem” function (shown below), and then remove the images from the display after a certain amount of time. The texture memory drops once the images are cleared from the display, even if you don’t take the full (and expected) step of nil’ing out the reference.
[lua]
local function checkMem()
collectgarbage(“collect”)
local memUsage_str = string.format( “MEMORY = %.3f KB”, collectgarbage( “count” ) )
print( memUsage_str, "TEXTURE = "…(system.getInfo(“textureMemoryUsed”)/1048576) )
end
timer.performWithDelay( 1000, checkMem, 0 )
local im = display.newImage(“image1.png”)
local im2 = display.newImage(“image2.png”)
local function rem()
display.remove(im)
display.remove(im2)
end
timer.performWithDelay( 4500, rem )
[/lua]