Question on Memory Usage

My Groups are in tables, like this:

group = {} group[1] = display.newGroup() group[2] = display.newGroup() group[3] = display.newGroup()

I use this group for scrolling(left->right and vice versa)

if I use this:

group[whateverNumber]:removeSelf() group[whateverNumber]=nil

Will it remove the objects on it only? or the group itself will be removed?

with regards to memory, if it the display.group is not removed will it consume memory?

The group itself will be removed, with its contents.   Setting the object to nil decrement the reference count to it and make it eligible for garbage collection (assuming there are no other references to it), freeing up memory allocated to it.

I also like to recommend using display.remove(object) instead of object:removeSelf() as defensive programming.

The only difference is that display.remove(object) will not fail if object==nil, where object:removeSelf will cause a runtime exception.

The group itself will be removed, with its contents.   Setting the object to nil decrement the reference count to it and make it eligible for garbage collection (assuming there are no other references to it), freeing up memory allocated to it.

I also like to recommend using display.remove(object) instead of object:removeSelf() as defensive programming.

The only difference is that display.remove(object) will not fail if object==nil, where object:removeSelf will cause a runtime exception.