[英]CGContextDrawPDFPage memory leak
你好,这是我在CATiledlayer中绘制pdf的代码
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
CGContextSetRGBFillColor(ctx, 1.0, 1.0, 1.0, 1.0);
CGContextFillRect(ctx, CGContextGetClipBoundingBox(ctx));
CGContextTranslateCTM(ctx, 0.0, layer.bounds.size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
CGContextConcatCTM(ctx, CGPDFPageGetDrawingTransform(myPageRef, kCGPDFCropBox, layer.bounds, 0, true));
CGContextDrawPDFPage(ctx, myPageRef);
}
一切都很好但我在下面的行中得到了内存泄漏警告
CGContextDrawPDFPage(ctx, myPageRef);
这里的myPageRef是CGPDFPageRef
我从github下载了代码并进行了一些研发,发现,
我忘了在我的TiledView的dealloc
方法中发布CGPDFPageRelease(myPageRef)
。
写完这段代码后我的内存泄漏就解决了....
// Clean up.
- (void)dealloc {
CGPDFPageRelease(myPageRef);
[super dealloc];
}
调用
CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
CGContextSetRenderingIntent(context, kCGRenderingIntentDefault);
在CGContextDrawPDFPage
解决了我的类似问题之前。
致于Johann的回答: CGContextDrawPDFPage占用了大量内存
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.