我有下面的代碼中的內存泄漏問題。盡我所知,我不明白爲什麼問題仍然存在,但在被調用時仍然不釋放。我在儀器檢測的問題,下面的代碼是保持其「卡」類活着,即使它應該已經釋放了他們。 歡迎任何幫助。內存泄漏問題
...
...
-(id)initDeckWithCardsPicked: (NSMutableArray*)cardsPicked andColors:(NSMutableArray*)cardColors
{
self = [self init];
if (self != nil) {
int count = [cardsPicked count];
for (int i=0; i<count; i++) {
int cardNum = [[cardsPicked objectAtIndex:i] integerValue];
Card * card = [[MemoryCard alloc] initWithSerialNumber:cardNum position: CGPointZero color:[cardColors objectAtIndex:i]];
[_cards addObject: card];
[card release];
}
}
return self;
}
- (id) init
{
self = [super init];
if (self != nil) {
self.bounds = (CGRect){{0,0},[Card cardSize]};
self.cornerRadius = 8;
self.backgroundColor = kAlmostInvisibleWhiteColor;
self.borderColor = kHighlightColor;
self.cards = [NSMutableArray array];
}
return self;
}
...
...
我沒有通過的dealloc ... [_cards釋放]釋放陣列; [super dealloc]; ... 但是從我瞭解類是從其他地方引用,不允許釋放? – franz 2010-05-25 00:53:07