2012-01-20 4 views
0

내 앱에서 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]; 
} 
+0

메소드'getItemFromXmlElement'의 코드 – Nekto

+2

Instruments는이 루틴이 유출되었음을 사용자에게 알려주지 않으며이 루틴에서 생성 된 오브젝트 중 하나가 유출되었음을 알려주지 않습니다. 내 생각 엔 updatedFeedWithRSS에 전달 된 rssItems 배열이 updatedFeedWithRSS 또는 호출 한 항목에 의해 어느 시점에서 지나치게 유지됩니다. –

+0

감사합니다 스티븐, 나는 updatefeedWithRss에있는 아이템을 놓치는 것을 잊어 버렸습니다. 나는 이것을 결코 보지 못했을 것입니다, 대단히 감사합니다 !! – coderjoe

답변

0

이 루틴이 유출되었으며,이 루틴에서 생성 된 오브젝트 중 하나가 유출되었다는 것을 사용자가 알 수 없습니다.

내 생각에 updatedFeedWithRSS 또는 어떤 것으로 호출되어 updatedFeedWithRSS에 전달 된 rssItems 배열이 지나치게 유지됩니다. 우리가 이것을 확인하려면 코드를 에 많이 게시해야하며, 그만한 가치는 없습니다. 그냥 읽어보고 찾을 수 있는지 확인하십시오.

2

실행 대신 평소 "실행"을 "분석"당신에게 오류를 확인 . 이 코드에는 오류가 없습니다 (2 init -> 2 릴리스).

+0

나는 또한 어떤 오류도 없었다고 생각합니다. 확인해 주셔서 감사 드리겠습니다. – coderjoe

관련 문제