I’ve narrowed this memory leak down to the ‘sub’ group, but I don’t know what to do. Does anybody know what to do?
[blockcode]-- replacement vars
onDevice = false
g = display.newGroup()
local debug_mem = display.newText(“memusage”, 15,15,native.systemFont,15)
debug_mem:setTextColor(255,255,255)
function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
local function memcount()
collectgarbage(“collect”)
debug_mem.text = round(collectgarbage(“count”),2)
timer.performWithDelay(200,memcount)
end
memcount()
–View: Game Over
view_over = {}
function view_over:enter(pointer_old_view, score)
pointer_old_view() – remove old screen’s contents
local newhighscore = true
local gameover = display.newText(“Game Over”, 25 , 25, “copperplate”, 35)
gameover:setTextColor(245, 245, 245)
gameover.y = display.contentHeight/2 -75
gameover.x = display.contentWidth/2
g:insert(gameover)
local scoretext2 = display.newText(“Score:”, 25 , 25, “copperplate”, 17.5)
scoretext2.y = gameover.y + scoretext2.height + 5
scoretext2:setTextColor(245, 245, 245)
scoretext2.x = display.contentWidth/2
g:insert(scoretext2)
local play_again = display.newGroup()
local playagain_bg = display.newRoundedRect(50,50, 0.75 * gameover.width, display.contentHeight*.075, 10 )
playagain_bg:setFillColor(75,75,75)
play_again:insert(playagain_bg, true)
local playagain_txt = display.newText(“Play again”, 25 , 25, “copperplate”, 18)
playagain_txt:setTextColor(245, 245, 245)
play_again:insert(playagain_txt, true)
playagain_txt.y = playagain_txt.y - 2
play_again.x, play_again.y = display.contentWidth/2 , 250
g:insert(play_again)
end
function view_over:exit()
for i=g.numChildren,0,-1 do
g:remove(i)
g[i] = nil
end
end
function main()
view_over:enter(function() end, 3)
button1 = display.newRoundedRect(300,300,15,15,2)
button1:setFillColor(123,123,123)
toggle = false
local function blarg()
if toggle == false then
view_over:exit()
toggle = true
else
view_over:enter(function() end, 3)
toggle = false
end
end
button1:addEventListener(“touch”,blarg)
end
main()
[/blockcode] [import]uid: 7467 topic_id: 4373 reply_id: 304373[/import]