我有内存泄漏,无法搞清楚。基本上,我在这里做的是将图像拉入Mutable Dictionary并返回字典。
- (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点,当我将其泄漏时,它指向NSConcreteData。