在iOS 8.1下,使用CGContextDrawPDFPage将PDF页面呈现到图形上下文中时出现内存泄漏。在模拟器中并没有发生这种情况,但是每次(在iPad Air上),都会发生数百次272字节的malloc内存泄漏。如果我注释掉CGContextDrawPDFPage,泄漏将消失。
还有其他人会得到类似的行为吗?
CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((CFDataRef)data);
CGPDFDocumentRef pdf = CGPDFDocumentCreateWithProvider(dataProvider);
CGPDFPageRef page;
// Grab the PDF page
page = CGPDFDocumentGetPage(pdf, pageNo + 1);
UIGraphicsBeginImageContext(aRect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, 0, aRect.size.height);
CGContextScaleCTM(context, 1, -1);
CGContextDrawPDFPage(context, page); // <- LEAKING?!?!?
// Would create the new UIImage from the context
//image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGPDFDocumentRelease(pdf);
CGDataProviderRelease(dataProvider);
Run Code Online (Sandbox Code Playgroud)
这是堆栈跟踪(反向):
分配
38.58 MB 36.7%148743 std :: __ 1 ::列表> ::列表(std :: __ 1 ::列表> const&)
19.61 MB 18.6%75610 std :: __ 1 :: …