Cleaning objects from memory and groups

I’ve used the following code for about 2 weeks with previous betas, but now it doesn’t seem to work.
Simulator shows something like: “Warning: Attempting to nil property(n)…”

[lua] cleanThisGroup = function ( event )

print ( “cleaner 1.” )
for i = nameGroup.numChildren , 1 , -1 do
local child = nameGroup[i]
nameGroup.parent:remove ( child )
end
for i = nameGroup.numChildren , 1 , -1 do
nameGroup[i] = nil
end

end[/lua]

I’ve read this code here, but I don’t remember where.
So now it doesn’t seem to work, at least the second part. I think that the game is able to remove objects from groups, but it doesn’t nil them.

Thanks! :smiley: [import]uid: 7022 topic_id: 1587 reply_id: 301587[/import]

Check the release notes for beta 7, there were some changes to how this works. [import]uid: 54 topic_id: 1587 reply_id: 4561[/import]

There currently is a long discussion about this in the thread “Error setting an array object to nil”. I had the same problem. Apparently with the new release you no longer need to nil an object to remove it from memory. Removing is enough to convert it to a plain table where it is taken care of by the garbage collector. There is a clear explanation of this process in the thread I mentioned. [import]uid: 6397 topic_id: 1587 reply_id: 4570[/import]

:wink: Thanks tarenberg, I figured out it before going to sleep so I couldn’t reply. Ansca you did a wonderful work! My congrats for this feature.
When I first read Beta 7 memory management paragraph I didn’t understand, so I tried it in my upcoming game and it worked like a charm. :wink:
Thanks again. [import]uid: 7022 topic_id: 1587 reply_id: 4573[/import]