简体   繁体   中英

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. 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. 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。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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