1


I'm working on several apps which are basically a PDF readers. Since iOS 6, apps started crashing because of being out of memory. Our apps utilize PDF Reader, but a problem is not related to it. So far we found out:
1. leaking comes from CGContextDrawPDFPage
2. it is not there (or not so prominent) in iOS <6
3. leak does not occur on PDFS with no or small compression

To be specific: after opening a PDF with some compression, some memory is used. When PDF is closed, part of that memory is released. However, not all of it. You can easily get memory warning and then crash the app just by opening & closing PDF several times.
I've tried also PSPDF and although, it has advantages (speed) over PDF Reader, it's much more expensive and the same leaking is in there.

I have created very simple test project for PDF Reader and PSPDF Kit. (you just need to add some PDF to project)

Is there anything I can do to fix leaking in iOS 6 or am I doing something wrong and there is actually no leaking? My current approach is to wait for official fix.
I know the issue was discussed heavily here, but I believe my situation is a little bit different. (using ARC and tested libraries, leaking visible in simulator and on devices)

Thank you.

xius
  • 596
  • 1
  • 6
  • 20
  • I feel you. I'm also in the same place as you are right now. As what I have searched, the cached datas are the ones responsible.(Explained here http://www.openradar.appspot.com/radar?id=126402 which is not that reliable 'cause it's old. Not sure though.). But I also have the same problem with ios 5.1(leak). I'm not using ARC. But from what I've read that ARC won't help the QuartzCore parts on releasing. – otakuProgrammer Jan 04 '13 at 04:50
  • @otakuProgrammer Colleague of mine claims we have problem with 5.1 on original iPad. I've also read that bug on openradar but for us it's not crashing because of a lot of pages, but because of not releasing all the memory when a PDF viewing is properly closed. It looks related, though. The worst thing is, it works on iOS 5.0. – xius Jan 04 '13 at 07:29
  • As for radar, most likely that was what he meant the "unreleased memory". Oh, so it doesn't work on the latest versions. Well hopefully, this will be answered 'cause it has been a problem on 2 applications that I am currently doing. =( – otakuProgrammer Jan 07 '13 at 07:21

1 Answers1

0

After a lot of trying, I've found out only two solutions. None of them is perfect, though.

1) Use Apple's QuickLook framework
- It is not leaking in iOS <6.0
- It is not leaking in iOS 6.0.

QuickLook runs in another process using XPC. However, that also means there is practically no customization. (see this question with a linked blog post)

2) Use FastPdfKit library
There seems to be no CGContextDrawPDFPage involved or maybe just some clever optimizations, but FastPdfKit is not leaking. Disadvantages are two - library is commercial and its rendering engine won't be shown to you even after you buy a license. You can use a free version with all the features, but there is a splash screen.

As we're under a time pressure and can't afford neither to wait for official bugfix, nor leave our current features out, we've chosen FastPdfKit.


I wouldn't consider this to be a definite answer. The library suits our needs, might not yours. Also, it is a commercial product. If there is more straightforward solution, I'll gladly accept it.

Community
  • 1
  • 1
xius
  • 596
  • 1
  • 6
  • 20