2011-07-01 1 views
0

메모리 누수가 있는데 알아낼 수 없습니다. 기본적으로, 내가 여기서하고있는 것은 이미지를 Mutable Dictionary로 가져 와서 사전을 반환하는 것이다.NSConcreteData를 가리키는 NSData 메모리 누수!

- (NSMutableDictionary *)loadImageDataGroup:(NSUInteger)index { 

int lim = 5; 
int sta = 0; 
if (index > lim) { 
    sta = index-lim; 
} 
int fin = (((lim*2)+1)+sta); 
if (fin > [self imageCount]) { 
    sta = ([self imageCount]-((lim*2)-1)); 
    fin = [self imageCount]; 
} 

BOOL firstTime = NO; 
if ([imagesLoaded count] == 0) { 
    firstTime = YES; 
} 

NSMutableDictionary *tempDict = [[[NSMutableDictionary alloc] init] autorelease]; 

for (int i = sta; i < fin; i++) { 

    NSString *imageName = [self imageNameAtIndex:i]; 

    if ([imagesLoaded valueForKey:imageName] == nil) { 

     // This is the Memory Leak...at least that is where Leaks is pointing me. 
     NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageName]]; 
     [tempDict setObject:imageData forKey:imageName]; 

    } else { 
     [tempDict setObject:[imagesLoaded valueForKey:imageName] forKey:imageName]; 
    } 

} 

return tempDict; 

}

누설이있는 NSData = * imageData의 스폿이고, I는 누수를 끌어 때 NSConcreteData 가리키는.

+1

, 그것은 반드시 누수가 그 라인에 의해 발생합니다 의미하지 않는다 :

은 다음을 참조하십시오. 사전 전체가 유출되거나 다른 누군가가 해당 NSData를 보유하고 릴리스하지 않을 수 있습니다. 나는 메모리의 관점에서 코드를 즉시 잘못 볼 수 없다. –

답변

0

코드를 보면 분명히 잘못된 것을 볼 수 없습니다. Instruments는 오 탐지 (false positive)를 유발할 수 있음을주지하십시오. 당신이있는 NSData가 유출되는 것을 볼 경우

Instruments showing false leak?