Memory Leak question
- by franz
I am having a memory leak issue with the following code. As much as I can tell I don't see why the problem persists but it still does not release when called. I am detecting the problem in instruments and the following code is keeping its "cards" classes alive even when it should had released them.
Any help welcome.
...
...
-(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;
}
...
...