Cocoa touch 使用大照片调用CGImageDestinationFinalize时崩溃

Cocoa touch 使用大照片调用CGImageDestinationFinalize时崩溃,cocoa-touch,Cocoa Touch,在下面的代码中,我在CGImageDestinationFinalize()行上崩溃。CGImage是一张大型JPG照片。如果我使用较小的JPG,效果很好。但是任何超过10MB的数据都会在“内存不足”的情况下崩溃 我认为CGImageDestination*方法正在对写入进行流式处理,但我一定是做错了什么,因为它保留了数据 在编写大型JPG时,是否应该使用其他API调用 BOOL SKImageWriteToDisk(CGImageRef image, NSURL *url, SKImagePr

在下面的代码中,我在CGImageDestinationFinalize()行上崩溃。CGImage是一张大型JPG照片。如果我使用较小的JPG,效果很好。但是任何超过10MB的数据都会在“内存不足”的情况下崩溃

我认为CGImageDestination*方法正在对写入进行流式处理,但我一定是做错了什么,因为它保留了数据

在编写大型JPG时,是否应该使用其他API调用

BOOL SKImageWriteToDisk(CGImageRef image, NSURL *url, SKImageProfile profile, CGFloat dpi)
{
    CFStringRef type = profile == SKmageProfileCompressed ? kUTTypeJPEG : kUTTypePNG;
    CGImageDestinationRef destination = CGImageDestinationCreateWithURL((__bridge CFURLRef)url, type, 1, NULL);
    if (!destination) {
        return NO;
    }

    NSMutableDictionary *properties =
    [@{
        (id) kCGImagePropertyDPIHeight: @(dpi),
        (id) kCGImagePropertyDPIWidth: @(dpi)
    } mutableCopy];
    if (profile == SKImageProfileCompressed) {
        properties[(id) kCGImageDestinationLossyCompressionQuality] = @(0.8f);
    }
    CGImageDestinationAddImage(destination, image, (__bridge CFDictionaryRef)properties);
    BOOL finalizeSuccess = CGImageDestinationFinalize(destination); // crash!
    CFRelease(destination);
    return finalizeSuccess;
}

面对同样的问题。我认为这是苹果图书馆的巨大内存缺陷。