Hello,
I'm reading PDF file, and then releasing it:
CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), (CFStringRef)@"somepdf.pdf", NULL, NULL);
CGPDFDocumentRef pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
int pagesCount = CGPDFDocumentGetNumberOfPages(pdf);
CGPDFDocumentRelease(pdf);
But the memory is not freed after release (checked that with Instruments). Why? What i'm missing in memory managment.
Thanks.
EDIT
here is my code:
- (void)loadView {
[super loadView];
CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), (CFStringRef)@"some.pdf", NULL, NULL);
pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
CFRelease(pdfURL);
CGPDFPageRef pdfPage = CGPDFDocumentGetPage(pdf, 1);
TiledPDFView * v = [[TiledPDFView alloc] initWithFrame:self.view.bounds andScale:1];
[v setPage:pdfPage];
[self.view addSubview:v];
UIButton * but = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[but setTitle:@"removeView" forState:UIControlStateNormal];
[but addTarget:self action:@selector(tests) forControlEvents:UIControlEventTouchDown];
but.frame = CGRectMake(0, 0, 100, 40);
[self.view addSubview:but];
}
-(void) tests {
[self.view removeFromSuperview];
[self.view release];
CGPDFDocumentRelease(pdf);
}
pdf
is instance variable.
TiledPDFView
- is uiview from ZoomingPDFViewer example. it draws CGPDFPageRef
using CATiledLayer
.
after i call tests
method, the view is removed (becomes invisible), but the memory allocated with CGPDFDocumentCreateWithURL
is not freed.