iOS 9.2上是否仍然存在CIContext内存泄漏?

Hen*_*olm 5 memory-leaks objective-c core-image ios swift

当使用带有EAGLContext的CIContext时,我在iOS 9.2上遇到了巨大的内存泄漏.我已经看到有关在iOS 9.1上解决这个问题的报道,但我无法确认.有没有人成功地删除了由CIContext drawImage,createCGImage和iOS 9.1或更高版本渲染引起的内存泄漏?

Apple Developer Forum上查看此问题

我已经通过使用MetalKit和MLKDevice测试了丢弃EAGLContext.我已经测试过使用CIContext的不同方法,比如drawImage,createCGImage和render,但似乎没什么用.

很明显,这是iOS 9.2中的一个错误.从Apple下载示例应用程序(见下文),然后在iOS 8.4的设备上运行相同的项目,然后在iOS 9.2的设备上运行,并注意Xcode中的内存量表.

下载https://developer.apple.com/library/ios/samplecode/AVBasicVideoOutput/Introduction/Intro.html#//apple_ref/doc/uid/DTS40013109

将其添加到APLEAGLView.h:20

@property (strong, nonatomic) CIContext* ciContext;
Run Code Online (Sandbox Code Playgroud)

用此替换APLEAGLView.m:118

[EAGLContext setCurrentContext:_context];
 _ciContext = [CIContext contextWithEAGLContext:_context];
Run Code Online (Sandbox Code Playgroud)

最后用这个替换APLEAGLView.m:341-343

glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);  

    @autoreleasepool  
    {  
        CIImage* sourceImage = [CIImage imageWithCVPixelBuffer:pixelBuffer];  
        CIFilter* filter = [CIFilter filterWithName:@"CIGaussianBlur" keysAndValues:kCIInputImageKey, sourceImage, nil];  
        CIImage* filteredImage = filter.outputImage;  

        [_ciContext render:filteredImage toCVPixelBuffer:pixelBuffer];  
    }  

glBindRenderbuffer(GL_RENDERBUFFER, _colorBufferHandle);  
Run Code Online (Sandbox Code Playgroud)