proper object cleanup

Hi,

we are adding all objects on screen to a array and calling a cleanup function to remove those objects. we also are using director 1.3, but strangely it seems that the object is still lurking (or we are not removing it properly)

here is the code snippet
[lua]local addScreenObjs
local removeScreenObjs
screenObjs = {}

addScreenObjs = function(obj)
screenObjs[#screenObjs+1] = obj
end

removeScreenObjs=function()
local i
for i = #screenObjs,1,-1 do
local_group:remove(screenObjs[i])
screenObjs[i] = nil
end

– create screen
– some other code
– …

local cleanup()
removeScreenObjs()
– print (somebutton.x)
end
end[/lua]

The point is after caling removeObjs, if we print the position of a button for eg which was supposedly removed, it still appears to be lurking around. we even tried forced garbage collection which did not help either.

what is the right way to remove displayobjects? is it different if we dont or use director?

thanks

[import]uid: 55009 topic_id: 12849 reply_id: 312849[/import]

local_group:removeSelf()

it will delete local_group and all the object inserted in it

even more if you are using director then no need to call the local_group:removeSelf() director will remove that for you just make sure you had inserted all display objects in local_group

:slight_smile: [import]uid: 12482 topic_id: 12849 reply_id: 47145[/import]

hi, we are using director and still seeing the memory issue as mentioned. the memory which seems to increase is the one which is monitored using collectgarbage(count) in LUA. The texture memory does seem to be normally coming back to its initial value [import]uid: 55009 topic_id: 12849 reply_id: 47309[/import]

as the texture memory is normal then may be it is not issue of any display object may be you need to chk about tables and variables [import]uid: 12482 topic_id: 12849 reply_id: 47407[/import]