如果我不释放自动释放的对象(self.graphicsContainer),我有 cocos2d 类会产生内存泄漏。代码:
@property (nonatomic, retain) CCNode * graphicsContainer; // I create property
@synthesize graphicsContainer = _graphicsContainer; // I synthesize it
-(id)init
{
if ((self = [super init])) {
self.graphicsContainer = [CCNode node]; // which returns autoreleased object!
}
return self;
}
-(void) dealloc
{
[self.graphicsContainer release]; // If I do not release it I get memory leak warning!
[super dealloc];
}
有谁知道我为什么要发布它?据我所知,我不应该释放自动释放的对象?