我在樂器中出現了內存泄漏......我之前已經排序了一些內容,但是這個已經讓我難倒了!如果你能幫助,我會非常感激......這是泄漏的方法......它需要一個數據字典,根據它創建一個新的並返回它。我已經評論了泄漏的線條,以及它泄漏的百分比(不知道這是什麼意思),我試圖通過選擇alloc/init/release而不是autorelease來清理一些東西,但是似乎沒有任何區別...爲什麼我有內存泄漏?我無法解決這個問題
- (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;
}
任何幫助非常感謝!謝謝!
:-Joe
構建和分析是什麼意思?在這樣的方法中尋找潛在的泄漏通常是相當不錯的。 – theMikeSwan 2010-08-25 21:19:34