Doing 1 seems to free up a lot of nodes in my game, but I didn't think that was necessary as I'm pointing _childNode to another node right below, so I thought the node I was originally pointing to (and _childChildNode) would have a refcount of 0 and would be deallocated?
You need to remove _childNode
from its parent:
[_childNode removeFromParent];
Until you do that, _childNode
stays in memory, because parent node holds a reference to _childNode
. Moreover, if you call removeFromParent
, calling removeAllChildren
is redundant.
After assigning a new node to _childNode
, you have to add it to _worldNode
again, because it is a completely new node:
_childNode = [SKNode node];
_anotherChildChildNode = [SKSpriteNode spriteNodeWithImageNamed:@"test"];
[_childNode addChild:_anotherChildChildNode];
[_worldNode addChild:_childNode];