Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS Core Graphics PDF memory managment problem
    primarykey
    data
    text
    <p>I'm reading PDF file, and then releasing it:</p> <pre><code>CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), (CFStringRef)@"somepdf.pdf", NULL, NULL); CGPDFDocumentRef pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL); int pagesCount = CGPDFDocumentGetNumberOfPages(pdf); CGPDFDocumentRelease(pdf); </code></pre> <p>But the memory is not freed after release (checked that with Instruments). Why? What i'm missing in memory managment.</p> <p>Thanks.</p> <p>EDIT</p> <p>here is my code:</p> <pre><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); } </code></pre> <p><code>pdf</code> is instance variable. <code>TiledPDFView</code> - is uiview from ZoomingPDFViewer example. it draws <code>CGPDFPageRef</code> using <code>CATiledLayer</code>.</p> <p>after i call <code>tests</code> method, the view is removed (becomes invisible), but the memory allocated with <code>CGPDFDocumentCreateWithURL</code> is not freed.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload