简体   繁体   English

CGPDFDocumentRef iOS 10内存泄漏

[英]CGPDFDocumentRef iOS 10 memory leak

This is more of a question and an answer. 这更多是一个问题和一个答案。 I had noticed in iOS 9 I had no memory issues using the CGPDF Library, and flipped through x amount of pages with no issues. 我注意到在iOS 9中,使用CGPDF库没有内存问题,并且翻阅了x个页面,没有任何问题。 See the attached screenshot, notice each page swipe the memory went down: 请参阅随附的屏幕截图,请注意每页轻扫内存已失败: iOS 9乐器分配/泄漏

However in iOS 10, the exact same PDF and code had a crashing issue when you swipe a certain amount of pages. 但是,在iOS 10中,当您滑动一定数量的页面时,完全相同的PDF和代码会出现崩溃问题。 The app would crash from memory allocations. 该应用程序将因内存分配而崩溃。 See attached screenshot, continuous rise in memory: 参见所附的屏幕截图,内存不断增加:

iOS 10分配

I'm posting this as a question of if anyone else has encountered this issue with iOS 10, how I fixed the issue was to CGPDFDocumentRelease in the didReceiveMemory warning and then immediately reload my CGPDFDocument, which let the app continue without crashing on iOS 10. After adding the release in the didReceiveMemory, my instruments looks like this, I have not tested on iOS 11 beta yet: 我将其发布为一个问题,如果有人在iOS 10上遇到此问题,我如何解决该问题是在didReceiveMemory警告中解决了CGPDFDocumentRelease,然后立即重新加载了CGPDFDocument,这使该应用程序可以继续运行而不会在iOS 10上崩溃。在didReceiveMemory中添加发行版后,我的仪器如下所示,我尚未在iOS 11 beta上进行过测试:

修复后的iOS 10

解决方法是在didReceiveMemory警告中添加CGPDFDocumentRelease,然后立即重新加载我的CGPDFDocument。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM