Hi I have a question on texture memories. I have written a simple program using the sample code in Corona on button UI.
The program allows me to display images (in this case 3, see code below) by clicking the left and right button. I realised that the images are taking up the texture memories once they are displayed on the screen. I knew the answer is something to do with removeSelf (). Read the tutorial available but found that it is not as simple as it seem.
Will it be possible to remove previous images whenever I click a left or right button??
I hope someone can help me as this is problem has kept me awake for a while now 
[code]
display.setStatusBar (display.HiddenStatusBar)
local lastCheck = {sysMem = 0, textMem = 0}
Runtime:addEventListener(‘enterFrame’, function()
– watch for leaks
collectgarbage()
local sysMem = collectgarbage(“count”) * 0.001
local textMem = system.getInfo( “textureMemoryUsed” )*0.000001
if lastCheck.sysMem ~= sysMem or lastCheck.textMem ~= textMem then
lastCheck.sysMem = sysMem
lastCheck.textMem = textMem
print ("mem: " … math.floor(sysMem*1000)*0.001 … "MB \t " … math.floor(textMem*1000)*0.001 … “MB”)
end
end)
local ui = require(“ui”)
local t = ui.newLabel{
bounds = { 10, 460, 300, 40 },
text = “”,
font = “”,
textColor = { 255, 204, 102, 255 },
size = 18,
align = “center”
}
local p = 0
switchOn = true
local img = {“1.png”,“2.png”, “3.png”}
local buttonHandler1 = function( event )
if event.phase == “release” then
if p>=3 then
t:setText (“last picture click left”)
elseif event.phase ==“release” then
p=p+1
local image1 = display.newImage(img[p], 0, 0)
image1.x=160; image1.y=200
switchOn=true
end
end
end
local buttonHandler2 = function( event )
if event.phase == “release” then
if p<=1 then
t:setText (“clight right for pic”)
elseif p>=2 and event.id == “button2” then
p=p-1
local image = display.newImage (img[p],0,0)
image.x=160; image.y=200
switchOn=true
end
end
end
local button1 = ui.newButton{
default = “btnRight.png”,
over = “btnRightPress.png”,
onEvent = buttonHandler1,
id = “button1”,
emboss = true
}
local button2 = ui.newButton{
default = “btnLeft.png”,
over = “btnLeftPress.png”,
onEvent = buttonHandler2,
id = “button2”,
emboss = true
}
button1.x = 280; button1.y = 430
button2.x = 190; button2.y = 430
[import]uid: 86993 topic_id: 15957 reply_id: 315957[/import]