В моем приложении есть метод для получения RSS-канала, и инструменты показывают, что у меня утечка памяти в моем методе выборки.
NSData* xmlData = [[NSMutableData alloc] initWithContentsOfURL:[NSURL URLWithString: kRSSUrl] ];
NSError *error;
GDataXMLDocument* doc = [[GDataXMLDocument alloc] initWithData:xmlData options:0 error:&error];
if (doc != nil) {
self.loaded = YES;
NSArray* items = [[doc rootElement] nodesForXPath:@"channel/item" error:&error];
NSMutableArray* rssItems = [NSMutableArray arrayWithCapacity:[items count] ];
for (GDataXMLElement* xmlItem in items) {
[rssItems addObject: [self getItemFromXmlElement:xmlItem] ];
}
[self.delegate performSelectorOnMainThread:@selector(updatedFeedWithRSS:) withObject:rssItems waitUntilDone:YES];
} else {
[self.delegate performSelectorOnMainThread:@selector(failedFeedUpdateWithError:) withObject:error waitUntilDone:YES];
}
[doc autorelease];
[xmlData release];
Инструменты выбрасывают это:
Leaked Object # Address Size Responsible Library Responsible Frame
Malloc 16 Bytes,4 < multiple > 64 Bytes appname -[RSSLoader fetchRss]
РЕДАКТИРОВАТЬ
Мой метод getItemFromXmlElement:
-(NSDictionary*)getItemFromXmlElement:(GDataXMLElement*)xmlItem
{
return [NSDictionary dictionaryWithObjectsAndKeys:
[[[xmlItem elementsForName:@"title"] objectAtIndex:0] stringValue], @"title",
[[[xmlItem elementsForName:@"link"] objectAtIndex:0] stringValue], @"link",
[[[xmlItem elementsForName:@"description"] objectAtIndex:0] stringValue], @"description",
nil];
}