Hi,
I would like to know what should I nil and remove by myself and what I can leave that won’t cause any memory leaks?
I know those 2 pages but I need reassurance from someone.
http://www.coronalabs.com/blog/2012/09/05/faq-wednesday-removing-event-listeners-and-display-objects/
http://www.coronalabs.com/blog/2012/07/03/properly-removing-objects-and-variables/
local screenW, screenH, halfW, halfH
local dragging
local p0\_moveGroup
local UIGroup
local graphic
local ui
function scene:createScene( event )
local group = self.view
screenW, screenH = display.contentWidth, display.contentHeight
halfW, halfH = display.contentWidth\*0.5, display.contentHeight\*0.5
dragging = false
p0\_moveGroup = display.newGroup()
UIGroup = display.newGroup()
graphic = {kath, ...,a lot of others}
ui = {nameK, ..., a lot of others}
...
code
...
graphic.kathG = display.newImageRect( p0\_moveGroup, "street/kathG.png",227,256);
graphic.kathG.x=halfW\*0.25
graphic.kathG.y = halfH
ui.nameK = display.newText(UIGroup, "Kath", 0, 0, "Munro", 12 )
ui.nameK:setReferencePoint( display.CenterReferencePoint )
ui.nameK.x = 3\*halfW
ui.nameK.y = 3\*halfH
ui.nameK:setTextColor( 255, 255, 255 )
ui.nameK.alpha = 0
...
code
...
group:insert(p0\_moveGroup)
group:insert(UIGroup)
end
...
code
...
function scene:enterScene( event )
local group = self.view
function moveCamera( event )
if ( event.phase == "began" ) then
local somethingX = event.x
dragging = true
p0\_moveGroup.x0 = event.x - p0\_moveGroup.x
p0\_moveGroup.y0 = event.y - p0\_moveGroup.y
...
code
...
end
end
...
code
...
I know that everything I insert into a “group” will be removed but do I have to do something with all other variables i.e nil “dragging”, “somethingX” or remove objects and nil “p0_moveGroup”, “UIGroup”, “graphic” and “ui” tables?
Thanks [import]uid: 117071 topic_id: 35738 reply_id: 335738[/import]