내 앱에서 rss 피드를 가져 오는 메서드가 있고 악기에서 내 fetch 메서드에서 메모리 누수가 있음을 보여줍니다.내 메서드에서 메모리 누수가
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];
}
메소드'getItemFromXmlElement'의 코드 – Nekto
Instruments는이 루틴이 유출되었음을 사용자에게 알려주지 않으며이 루틴에서 생성 된 오브젝트 중 하나가 유출되었음을 알려주지 않습니다. 내 생각 엔 updatedFeedWithRSS에 전달 된 rssItems 배열이 updatedFeedWithRSS 또는 호출 한 항목에 의해 어느 시점에서 지나치게 유지됩니다. –
감사합니다 스티븐, 나는 updatefeedWithRss에있는 아이템을 놓치는 것을 잊어 버렸습니다. 나는 이것을 결코 보지 못했을 것입니다, 대단히 감사합니다 !! – coderjoe