Hi all,
I've got a memory leak in Instruments... I've sorted some before, but this one has left me stumped! I would be very grateful if you could help... This is the method with the leak... It takes in a dictionary of data, creates a new based on it and returns it. I've commented the lines with the leaks, and the percentages it gives the leak (not sure what that's all about), I've tried to clean things up a bit by choosing to alloc/init/release instead of autorelease, but that doesn't seem to make any difference...
- (PetalLayerView *)makePetalLayerWithData:(NSDictionary *)sectionData isZeroIndexed(BOOL)zeroIndexed
{
NSMutableSet *petalsData = [[NSMutableSet alloc] init]; // 7.2%
NSArray *sections = [sectionData objectForKey:@"sections"];
NSNumber *startIndex, *endIndex;
NSDictionary *petalData;
for(int i=0; i<sections.count; i++)
{
startIndex = [sections objectAtIndex:i];
if(i < sections.count - 1)
endIndex = [sections objectAtIndex:i+1];
else
endIndex = [sections objectAtIndex:0];
if(!zeroIndexed)
{
startIndex = [NSNumber numberWithInt:[startIndex intValue]-1]; // 10.2%
endIndex = [NSNumber numberWithInt:[endIndex intValue]-1]; // 10.5%
}
petalData = [[NSDictionary alloc] initWithObjectsAndKeys:startIndex, @"startIndex", endIndex, @"endIndex", nil]; // 64.4%
[petalsData addObject:petalData]; // 7.7%
[petalData release];
}
int maxLength = MAX(self.frame.size.width, self.frame.size.height);
CGRect petalFrame = CGRectMake((self.frame.size.width - maxLength)/2, (self.frame.size.height - maxLength)/2, maxLength, maxLength);
PetalLayerView *petalLayerView = [[[PetalLayerView alloc] initWithFrame:petalFrame] autorelease];
NSString *tagGroupName = [sectionData objectForKey:@"section_name"];
WheelModel *wheelModel = [WheelModel sharedInstance];
if([sectionData objectForKey:@"filtered"])
{
petalLayerView.outlineColor = [wheelModel.tagColors objectForKey:tagGroupName];
}
petalLayerView.petalColor = [wheelModel.petalColors objectForKey:tagGroupName];
petalLayerView.petalsData = petalsData;
[petalsData release];
return petalLayerView;
}
Any help much appreciated! Thanks!
:-Joe