开发者

PDF pages don't free completely!

开发者 https://www.devze.com 2023-02-17 00:07 出处:网络
I\'ve been working for a long time with displaying pdf pages. In my app i should re-display pdf pages for million times - but every time when i free my page - [view release]) when using Tools - Alloca

I've been working for a long time with displaying pdf pages. In my app i should re-display pdf pages for million times - but every time when i free my page - [view release]) when using Tools - Allocations - i see that some space is always left - and when i recreate my view with draw:inRect - where pdf is displayed, even if it is the same as previous (thought, that some information is stored like some pre-cache)

Anybody had same problem ? especially if u use pdf-page with size of 5Mb or more - your app will crash in some time

basic drawing - smth like this:

- (id)initWithFrame:(CGRect)frame {
    if ((self = [super initWithFrame:frame])) {
        // Initialization code
        self.backgroundColor = [UIColor clearColor];

        NSString *pdfStringURL = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"pdf"];
        NSURL *pdfURL = [NSURL fileURLWithPath:pdfStringURL];

        pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);

    }
    return self;
}


- (void)drawRect:(CGRect)rect {
    CGPDFPageRef pdfPage2 = CGPDFDocumentGetPage(pdf, 1);

    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGContextTranslateCTM(ctx, -13, self.frame.size.height+15);
    CGContextScaleCTM(ctx, 1.1, -1.1);
    CGContextConcatCTM(ctx, CGPDFPageGetDrawingTransform(pdfPage2, kCGPDFCropBox, self.frame, 0, true));
    CGContextSetInterpolationQuality(ctx, kCGInterpolationNone);
    CGContextSetRenderingIntent(ctx, kCGRenderingIntentDefault);
    CGContextDrawPDFPage(ctx, pdfPage2);

}


- (void)dealloc {
    CGPDFDocumentRele开发者_如何学Pythonase(pdf);
    [super dealloc];
}
}

how can i free memory completely!?

0

精彩评论

暂无评论...
验证码 换一张
取 消