我得到的内存压力警告为我的iPhone 4与以下情况: 我需要上传我的图像到服务器,并使用亚马逊s3。我将我的选择图像分成NSMutableData
与下面的代码:获取内存泄漏 - NSData转换
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL);
CFDictionaryRef options = (__bridge CFDictionaryRef)@{(id)kCGImageSourceCreateThumbnailWithTransform: (id)kCFBooleanTrue,
(id)kCGImageSourceCreateThumbnailFromImageIfAbsent: (id)kCFBooleanTrue,
(id)kCGImageSourceThumbnailMaxPixelSize: [NSNumber numberWithDouble: maxSize],
(id)kCGImageDestinationLossyCompressionQuality: [NSNumber numberWithDouble:compressionQuality]};
CGImageRef thumbnail = CGImageSourceCreateThumbnailAtIndex(source, 0, options); // Create scaled image
CFStringRef UTI = kUTTypeJPEG;
NSMutableData *destData = [NSMutableData data];
CGImageDestinationRef destination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)destData, UTI, 1, NULL);
if (!destination) {
NSLog(@"Failed to create image destination");
}
CGImageDestinationAddImage(destination, thumbnail,(__bridge CFDictionaryRef)metadata); // copy all metadata in source to destination
if (!CGImageDestinationFinalize(destination)) {
NSLog(@"Failed to create data from image destination");
}
if (!destination) CFRelease(destination);
CFRelease(source);
CFRelease(thumbnail);
return [destData copy];
为什么我会得到24后的图像内存警告,当我在循环中执行呢?
的iPhone4已经具有非常低的内存,是它在其他设备中发生的事情,是你打开使用其他技术来上传图片到服务器? –
谢谢Saheb,是的,只在iPhone 4上面临这个问题。 bcoz我已经尝试过使用iPhone 6和iPhone 5s,并且图片数量可能超过50张图片。是否有可能通过内存级别修复 – vetrivel