你好,这是我在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
发布于 2011-06-13 17:39:26
我从github下载了代码并做了一些研发,发现
我忘了在我的TiledView的dealloc方法中释放CGPDFPageRelease(myPageRef)。
在写完这段代码后,我的内存泄漏问题就解决了……
// Clean up.
- (void)dealloc {
CGPDFPageRelease(myPageRef);
[super dealloc];
}发布于 2011-08-11 16:32:30
呼叫
CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
CGContextSetRenderingIntent(context, kCGRenderingIntentDefault);在CGContextDrawPDFPage解决了我的类似问题之前。
答案归功于约翰:CGContextDrawPDFPage taking up large amounts of memory
https://stackoverflow.com/questions/5231613
复制相似问题