1
votes

I'm creating a game on iphone with Cocos2D. I do know that I can trust Cocos2D's memory management to free up the memory like CCScene,CCLayer that will be effectively freed when changing scene.

But when I have my custom class like XYPoint (contains 2 NSNumber*, which is X and Y) how can I do to have it free the memory along with CCScene/CClayer it belongs? (sounds like autorelease, but in Cocos2D I can't find any pool drain like ordinary cocoa touch program.)

(now I can only think about add a XYPoint's release on scene's 'after transition' method... )

thanks!

1

1 Answers

1
votes

Well, if those instances belong to a ccsprite subclass, just release them in the sprites dealloc call. Otherwise you will have to make a logical decision about when to release. Also make sure that you release sprites after you add them to layers so that when the layer is dealloced, the sprites will get released. Same goes for speitesheets, scenes, etc. All of the layout classes hold refs and retain the children.