FastPdfKit framework - Memory warnings causing app shutdown

jguengerich's Avatar


15 Sep, 2017 02:19 PM

Using the develop branch with Xcode 9. I am getting memory warnings, and my app is shut down, with some of my PDFs. For example, one PDF is 12.5 MB, but when I open it, the memory usage spikes up to almost 500 MB briefly (it eventually goes back to 10 or 12 MB). Then if I switch to 2 page mode, it spikes again and I get memory warnings. If I try to scroll to the next page, I get more memory warnings and the app is closed by iOS. These same PDFs can be opened by QuickLook, Adobe Reader, and iBooks without any problems. I have tried the following things, and they do not help.

            [pdfViewController hideThumbnails];
            pdfViewController.backgroundThumbnailRenderingEnabled = NO;
            documentManager.fontCacheEnabled = NO;
            pdfViewController.previewsCount = 1;
            pdfViewController.overlayEnabled = NO;
            documentManager.conservativeMemoryUsage = YES;
            documentManager.conservativeMemoryUsageHint = 120000000;
Is there anything else I can do to make the FastPdfKit framework use less memory?
Also, it seems to take longer to render the pages than previous versions of the framework.
  1. Support Staff 1 Posted by Matteo on 19 Sep, 2017 08:25 AM

    Matteo's Avatar

    The PDFs with small disk size but large high resolution images are usually the worst offenders for memory spikes.

    You might want to try with a reduce the concurrency by initializing the MFDocumentManager using -(id)initWithFileUrl:(NSURL *)anUrl count:(NSUInteger)count. Default max is 4 - maybe it is a bit too happy - but you can try to lower it to 3.

    You might also want to use a different image ratio like
    reader.settings.imageScale = FPKImageScaleAnamorphic that will also help to reduce the memory footprint.

    I wouldn't change previewsCount as it will reduce the number of pre-loading pages but has usually little effects on spikes, especially when scrolling.

  2. 2 Posted by jguengerich on 19 Sep, 2017 01:52 PM

    jguengerich's Avatar

    Thanks Matteo, the image scale setting made a big difference. It is actually cacheImageScale, which leads to another question: Is the API documented anywhere? The API documentation link on this support site leads to a "parked" domain, and the Xcode docset link leads to a 404 error page. I have an old copy of the Xcode docset I must have downloaded several years ago, but it doesn't seem to have all the current info.

  3. Support Staff 3 Posted by Matteo on 20 Sep, 2017 07:27 AM

    Matteo's Avatar

    Strange, I expected the document count to be more incisive than the imageCacheScale.

    Most methods in the headers are documented, especially MFDocumentViewController and MFDocumentManager ones.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

15 Apr, 2020 04:25 AM
26 Feb, 2020 07:23 AM
27 Jun, 2019 06:08 AM
23 Nov, 2018 01:54 PM
14 Nov, 2018 04:37 PM