Tim I get a memory leak if you loop the function for creating img. How do you remove it completely with a loop?
The code I’m using:
[code]
local x = 100
local y = 4
local score = 0
scoreTextfield = display.newText( " " … score, 200, 105, nil, 40 )
scoreTextfield:setTextColor( 255, 255, 255, 255 )
scoreTextfield.text = " " … score
collectgarbage(“collect”)
score = "System Memory : " … collectgarbage(“count”)
scoreTextfield.text = " " … score
local randomPos = math.random
function deleteMe(event)
local targetObj = event.target
targetObj:removeSelf()
end
local function randomBall ()
local imageBall = display.newRect( randomPos(300), 200, 30, 30 )
imageBall:setFillColor ( 255, 255, 255 )
imageBall:addEventListener(“touch”, deleteMe)
end
local timerBall = timer.performWithDelay( x, randomBall, y )
local function memCheck ()
collectgarbage(“collect”)
score = "System Memory : " … collectgarbage(“count”)
scoreTextfield.text = " " … score
end
local timerCheck = timer.performWithDelay( 10000, memCheck, 1 )
[/code] [import]uid: 10903 topic_id: 3522 reply_id: 12281[/import]