for (int i=0; i<[images count] ;i++) {
url=@"http://192.168.0.101/titan/titanimages/";
url=[url stringByAppendingString:[images objectAtIndex:i]];
//NSData *imageData=[[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:url]];
NSData *imageData=[NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
destinationPath=[documentsDirectory stringByAppendingString:@"/modelimages"];
destinationPath=[destinationPath stringByAppendingPathComponent:[images objectAtIndex:i]];
[imageData writeToFile:destinationPath atomically:YES];
value=value+divideValue;
printf("%f\n",value);
[NSThread detachNewThreadSelector:@selector(updateProgressBar)toTarget:self withObject:nil];
}
此代码存在内存泄漏:它不释放 NSdata 的内存,并且在一段时间后应用程序的内存利用率达到 61 MB。谁能帮我摆脱困境?