Hi all,
I'm slowly progressing with my game thanks Sparrow. A couple of questions regarding memory managment have popped up though. Even though I've search around a lot on google I can't honestly say I understand it fully, though I think I've grasped the basic concepts.
1. In a function such as this:
-(id)initWithWidth:(float)width withHeight:(float)height atX:(float) atY:(float)y toObj:(Sprite*)targetObj inWorld:(b2World*)targetWorld
Should I release the initvars such as x, width, toObj etc?
2. I'm using an NSMutableSet to store my player animations such as this:
playerAnimationsArray = [[NSMutableSet alloc] init]; [playerAnimationsArray addObject:playerMC]; [playerAnimationsArray addObject:playerIdleMC]; [playerAnimationsArray addObject:playerJumpMC]; [playerAnimationsArray addObject:playerPushingMC];
After I've added these movieclips to the juggler on the main stage I tried to remove the array by doing [playerAnimationsArray release]; but if I do the game will crash. If I leave it out it runs fine. This is against the apparent rule that whenever you alloc something it will need to be released at some point. Can I just leave it be? I have a few other arrays that I can't seem to release either.
3. If I do a simulated memory warning in the ios simulator my game will crash. I have no clue what would be causing this. I have a dealloc function in each class in my game that calls [super dealloc];.
4. if I make properties in a class, should these be released? Also, how do I remove an entire object I've allocated the correct way?