I am not sure it will help or not but anyway you should move @autoreleasepool inside the 'for' loop, because now it has not so much sense:
- (void)getAllNewImagesAtLoad:(NSMutableArray *)arr {
// NSData *imagedata; tried defining variable here initially but didn't help
for (int i=0;i<[arr count];i++) {
@autoreleasepool {
int picID = [[arr valueForKey:@"PictureID"][i] intValue];
NSString* path = [helper tempPathForImage:picID];
if ([[arr valueForKey:@"DelFlag"][i] isEqualToString:@"delete"]) {
if ([[NSFileManager defaultManager] fileExistsAtPath:path] == YES) {
[[NSFileManager defaultManager] removeItemAtPath:path error:nil];
}
} else if ([[NSFileManager defaultManager] fileExistsAtPath:path] == YES) {
// do nothing
} else {
NSData *imagedata = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:imageurl]];
[imagedata writeToFile:path atomically:YES];
imagedata = nil;
}
NSNumber *val = [NSNumber numberWithInt:(int)(((i+1)*100)/[arr count])];
[self performSelectorOnMainThread:@selector(updateFunction:) withObject:val waitUntilDone:NO];
}
}
}