我正在与一个内部缓存(约90 MB的15MP图像)的战斗中
CGContextDrawImage
/
CGDataProviderCopyData
功能。
以下是探查器中的堆栈跟踪:
在所有情况下,
IOSurface
创建为“缓存”,并且在
@autoreleasepool
这给应用程序留下了很少的生存机会。
512x512
以及
4500x512
和
4500x2500
(全尺寸)图像块。
@自动释放池
,
CFGetRetainCount
返回
1
CG
操作数据的代码:
+ (void)render11:(CIImage*)ciImage fromRect:(CGRect)roi toBitmap:(unsigned char*)bitmap {
@autoreleasepool
{
int w = CGRectGetWidth(roi), h = CGRectGetHeight(roi);
CIContext* ciContext = [CIContext contextWithOptions:nil];
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef cgContext = CGBitmapContextCreate(bitmap, w, h,
8, w*4, colorSpace,
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGImageRef cgImage = [ciContext createCGImage:ciImage
fromRect:roi
format:kCIFormatRGBA8
colorSpace:colorSpace
deferred:YES];
CGContextDrawImage(cgContext, CGRectMake(0, 0, w, h), cgImage);
assert( CFGetRetainCount(cgImage) == 1 );
CGColorSpaceRelease(colorSpace);
CGContextRelease(cgContext);
CGImageRelease(cgImage);
}
}
表面
:它来自以前的私有框架
表面
.
CIContext
有功能
render: ... toIOSurface:
.
IOSurfaceRef
CGContextDrawImage
/
?
有一种方法可以禁用缓存吗?
3.为什么会发生缓存?
4.我可以使用一些较低级别(非私有)的API手动清理系统内存吗?
欢迎提出任何建议。