2011-03-08 21 views
5

Merhaba buradaCGContextDrawPDFPage hafıza

- (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); 
} 

Her şey yolunda CATiledlayer içinde pdf çizim benim kodudur sızıntı ama satırını

 CGContextDrawPDFPage(ctx, myPageRef); 

aşağıdaki bellek sızıntısı uyarı var bazı R & D github kodu indirip yapmak vardı ve bulunan bu

Ben

ve benim bellek sızıntısı çözüldü Bu kodu yazdıktan sonra

....

// Clean up. 

- (void)dealloc { 
    CGPDFPageRelease(myPageRef); 
    [super dealloc]; 
} 

cevap

5

CGPDFPageRef

olduğunu
+0

Yalnızca yapmalıyım bir noktada bunu muhafaza eğer. Ancak, sadece 'CGPDFDocumentGetPage' yapıyorsanız, bir otomatikleştirme nesnesi alırsınız ve bu nedenle onu serbest bırakmamalısınız. (Tabii ki, eğer onu korursanız, tabii ki bu cevapta önerildiği şekilde onu serbest bırakabilirsiniz). – Rob

+0

https://stackoverflow.com/questions/46903182/cgcontextdrawpdfpage-memory-leak-app-crash – Ravindhiran

3

CGContextDrawPDFPage önce

CGContextSetInterpolationQuality(context, kCGInterpolationHigh); 
CGContextSetRenderingIntent(context, kCGRenderingIntentDefault); 

çözüldü çağrılması .. benim TiledView ait dealloc yönteminde CGPDFPageRelease(myPageRef) serbest bırakmak unuttum benzer bir sorun benim.

Kredi Johann bu cevabı gider: CGContextDrawPDFPage taking up large amounts of memory

İlgili konular