この質問は何度か尋ねられましたが、私の場合は解決できませんでした。 CGContextDrawPDFPageはリーク計測器のリークとして表示されます。また、このコードセグメントを実行すると、アプリのクラッシュが発生します。これはメモリの問題によるものです。iOSリーク機器CGContextDrawPDFPage
pdfURLDocument = [[NSURL alloc] initFileURLWithPath: [docsDir stringByAppendingPathComponent:documentName]];
pdfDocument = CGPDFDocumentCreateWithURL((CFURLRef)pdfURLDocument);
[pdfURLDocument release];
page = CGPDFDocumentGetPage(pdfDocument, 1);
CGPDFPageRetain(page);
// determine the size of the PDF page
CGRect pageRect = CGPDFPageGetBoxRect(page, kCGPDFMediaBox);
pdfScaleWidth = (1/((CGFloat) gridSizeDocument)) * self.frame.size.width/pageRect.size.width;
pdfScaleHeight = (1/((CGFloat) gridSizeDocument)) * self.frame.size.height/pageRect.size.height;
pageRect.size = CGSizeMake(pageRect.size.width*pdfScaleWidth, pageRect.size.height*pdfScaleHeight);
// Create a low res image representation of the PDF page
UIGraphicsBeginImageContext(pageRect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
// First fill the background with white.
CGContextSetRGBFillColor(context, 1.0,1.0,1.0,1.0);
CGContextFillRect(context,pageRect);
CGContextSaveGState(context);
// Flip the context so that the PDF page is rendered
// right side up.
CGContextTranslateCTM(context, 0.0, pageRect.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
// Scale the context so that the PDF page is rendered
// at the correct size for the zoom level.
CGContextScaleCTM(context, pdfScaleWidth, pdfScaleHeight);
CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
CGContextSetRenderingIntent(context, kCGRenderingIntentDefault);
CGContextDrawPDFPage(context, page);
CGContextRestoreGState(context);
backgroundImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGPDFPageRelease(page);
また、CGPDFPageRelease(page)も含めました。 deallocメソッドで。また、小規模な文書ではうまく動作するが、大きな文書ではクラッシュするだけであることを付け加えると便利です。しかし、メモリリークは依然として小さいものでも持続します。
スタティックアナライザはあなたに何を伝えますか? –
これはいくつかのメモリリークを示していますが、それらのすべてがこの問題と完全に無関係のようです。 – user1120008