我想在iOS上呈现PDF,当我拨打CGPDFDocumentCreateWithURL()时,我得到内存泄漏。我知道这个问题之前已经讨论过,但我不知道我的情况是否因为我使用ARC而不同。CGPDFDocumentCreateWithURL ARC内存泄漏
我已经提取,并通过简化对我的viewDidLoad中运行下面的代码的问题:
// Bridge resourceRef to ARC with no ownership change (still owned by ARC)
CFURLRef resourceRef = (__bridge CFURLRef) [NSURL fileURLWithPath:htmlPath];
CGPDFDocumentRef pdf;
pdf = CGPDFDocumentCreateWithURL(resourceRef);
CGPDFDocumentRelease(pdf);
// Do not need to release resourceRef because ARC will release it
仪器告诉我说,泄漏的对象是一个malloc 48个字节,由CoreGraphics中负责。堆栈跟踪里面有CGPDFDocumentCreateWithURL。泄漏意味着在没有业主的情况下有物体存在。
我已经创建一个混帐回购协议的问题的复制: https://github.com/indika/PDFLeaks
任何想法。将不胜感激任何帮助或'指针'。
我可能已经找到了泄漏背后的原因:如果我的PDF从NSCachesDirectory目录,则相应发生泄漏。也许我应该使用不同的目录下载内容。 – indi
我可能是错误的泄漏依赖于目录的PDF位于 – indi
我从你的链接运行该项目,但它显示没有泄漏... – borrrden