我有下面的代码中的内存泄漏问题。尽我所知,我不明白为什么问题仍然存在,但在被调用时仍然不释放。我在仪器检测的问题,下面的代码是保持其“卡”类活着,即使它应该已经释放了他们。 欢迎任何帮助。内存泄漏问题
...
...
-(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