J'ai une fuite de mémoire dans les Instruments ... J'en ai trié avant, mais celui-ci m'a laissé perplexe! Je serais très reconnaissant si vous pouviez aider ... C'est la méthode avec la fuite ... Il prend dans un dictionnaire de données, crée un nouveau basé dessus et le renvoie. J'ai commenté les lignes avec les fuites, et les pourcentages qu'elle donne à la fuite (je ne sais pas de quoi il s'agit), j'ai essayé de nettoyer les choses un peu en choisissant alloc/init/release au lieu d'autorelease, mais ne semble pas faire de différence ...Pourquoi ai-je une fuite de mémoire? Je ne peux pas m'en sortir
- (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;
}
toute aide très appréciée! Merci!
: -Joe
Que disent construire et analyser? Il est généralement très bon de trouver des fuites potentielles dans une méthode comme celle-ci. – theMikeSwan