I appear to be leaking moving between two menu scenes:
main menu
module(..., package.seeall)
function new()
collectgarbage('collect')
print( "main, MemUsage: " .. collectgarbage("count") )
local local\_group = display.newGroup()
----------------------------------------------------------------------------------------
function ChangeScene(e)
if e.target.GameMode then
\_G.GAME\_MODE = e.target.GameMode
end
CleanupButtonListeners()
director:changeScene(e.target.Scene)
end
----------------------------------------------------------------------------------------
function OpenFeintDashboard()
\_G.openfeint.launchDashboard()
end
----------------------------------------------------------------------------------------
function SendEmail()
system.openURL("")
end
----------------------------------------------------------------------------------------
function ViewWebsite()
system.openURL("")
end
----------------------------------------------------------------------------------------
-- buttons
local title\_screen
local score\_attack
local time\_attack
local endless
local scores
local options
local help
local mail
local web
----------------------------------------------------------------------------------------
function init()
local buttonfactory = require "buttonfactory"
title\_screen = display.newImageRect('titlescreen.png', 320, 480)
title\_screen:setReferencePoint(display.TopLeftReferencePoint)
title\_screen.x = 0
title\_screen.y = 0
local\_group:insert(title\_screen)
local x\_pos = 15
score\_attack = buttonfactory.GetNewButton('Score Attack', "button", "button\_over", ChangeScene)
score\_attack:setReferencePoint(display.TopLeftReferencePoint)
score\_attack.x = x\_pos
score\_attack.y = 137.5
score\_attack.Scene = 'scoreattackmenu'
score\_attack.GameMode = 'SCORE\_ATTACK'
local\_group:insert(score\_attack)
time\_attack = buttonfactory.GetNewButton('Time Attack', "button", "button\_over", ChangeScene)
time\_attack:setReferencePoint(display.TopLeftReferencePoint)
time\_attack.x = x\_pos
time\_attack.y = 185.
time\_attack.Scene = 'timeattackmenu'
time\_attack.GameMode = 'TIME\_ATTACK'
local\_group:insert(time\_attack)
endless = buttonfactory.GetNewButton('Endless', "button", "button\_over", ChangeScene)
endless:setReferencePoint(display.TopLeftReferencePoint)
endless.x = x\_pos
endless.y = 234.
endless.Scene = 'gamemain'
endless.GameMode = 'ENDLESS'
local\_group:insert(endless)
scores = buttonfactory.GetNewButton('', "button\_of", "button\_of\_over", OpenFeintDashboard)
scores:setReferencePoint(display.TopLeftReferencePoint)
scores.x = x\_pos
scores.y = 283.
local\_group:insert(scores)
options = buttonfactory.GetNewButton('Options', "button", "button\_over", ChangeScene)
options:setReferencePoint(display.TopLeftReferencePoint)
options.x = x\_pos
options.y = 332.
options.Scene = 'options'
local\_group:insert(options)
help = buttonfactory.GetNewButton('', "help", "help\_over", ChangeScene)
help:setReferencePoint(display.CenterReferencePoint)
help.x = centerX - 53
help.y = 415
help.Scene = 'options'
local\_group:insert(help)
mail = buttonfactory.GetNewButton('', "mail", "mail\_over", SendEmail)
mail:setReferencePoint(display.CenterReferencePoint)
mail.x = centerX
mail.y = 415
local\_group:insert(mail)
web = buttonfactory.GetNewButton('', "web", "web\_over", ViewWebsite)
web:setReferencePoint(display.CenterReferencePoint)
web.x = centerX + 53
web.y = 415
local\_group:insert(web)
local copyright\_text = display.newText("Blah Blah Blah", 13)
copyright\_text:setTextColor(255, 255, 255)
local\_group:insert(copyright\_text)
local rights\_text = display.newText("All rights reservered", centerX, 465, 'Varela', 13)
rights\_text:setTextColor(255, 255, 255)
local\_group:insert(rights\_text)
end
----------------------------------------------------------------------------------------
function CleanupButtonListeners()
title\_screen:removeEventListener("touch", title\_screen)
score\_attack:removeEventListener("touch", score\_attack)
time\_attack:removeEventListener("touch", time\_attack)
endless:removeEventListener("touch", endless)
scores:removeEventListener("touch", scores)
options:removeEventListener("touch", options)
help:removeEventListener("touch", help)
mail:removeEventListener("touch", mail)
web:removeEventListener("touch", web)
end
init()
return local\_group
end
options menu
module(..., package.seeall)
----------------------------------------------------------------------------------------
function new()
collectgarbage('collect')
print("options, MemUsage: " .. collectgarbage("count") )
local local\_group = display.newGroup()
----------------------------------------------------------------------------------------
local title\_screen = display.newImageRect('options\_menu.png', 320, 480)
title\_screen:setReferencePoint(display.TopLeftReferencePoint)
title\_screen.x = 0
title\_screen.y = 0
local\_group:insert(title\_screen)
----------------------------------------------------------------------------------------
-- add volume controls
local StartX = 50
local EndX = 270
local music\_text = display.newText("Music", 80, 120, 'Varela', 20)
music\_text:setTextColor(255, 255, 255)
local music\_y = 160
local music\_line = display.newLine(StartX, music\_y, EndX, music\_y)
music\_line:setColor(255, 255, 255)
music\_line.width = 1
local sound\_text = display.newText("Sound FX", 100, 200, 'Varela', 20)
sound\_text:setTextColor(255, 255, 255)
local sound\_y = 240
local sound\_line = display.newLine(StartX, sound\_y, EndX, sound\_y)
sound\_line:setColor(255, 255, 255)
sound\_line.width = 1
local\_group:insert(music\_text)
local\_group:insert(music\_line)
local\_group:insert(sound\_text)
local\_group:insert(sound\_line)
----------------------------------------------------------------------------------------
local back\_button
local credits\_button
----------------------------------------------------------------------------------------
function ChangeScene(e)
if e.target.Scene then
\_G.GameAudio.SaveSoundSettings()
back\_button:removeEventListener("touch", back\_button)
credits\_button:removeEventListener("touch", credits\_button)
director:changeScene(e.target.Scene)
end
end
----------------------------------------------------------------------------------------
back\_button = buttonfactory.GetNewButton('Back', "button\_medium", "button\_medium\_over", ChangeScene)
back\_button.x = centerX
back\_button.y = screenHeight \* 0.80
back\_button.Scene = 'mainmenu'
local\_group:insert(back\_button)
credits\_button = buttonfactory.GetNewButton('Credits', "button\_medium", "button\_medium\_over", ChangeScene)
credits\_button.x = centerX
credits\_button.y = screenHeight \* 0.70
credits\_button.Scene = 'credits'
local\_group:insert(credits\_button)
return local\_group
end
output:
Output string :: main, MemUsage: 197.5576171875
Output string :: options, MemUsage: 234.517578125
Output string :: main, MemUsage: 238.8447265625
Output string :: options, MemUsage: 242.0849609375
Output string :: main, MemUsage: 239.2744140625
Output string :: options, MemUsage: 242.5615234375
I’m at a complete loss on this one, I cannot see where I am leaking [import]uid: 68937 topic_id: 12808 reply_id: 312808[/import]