1
votes

We are currently using a QLPreviewController to load a collection of PDFs. The size of the collection can range from 16, 95, or even 1600+ PDFs. Due to the data source of the PreviewController containing multiple items we now have the ability to swipe left or right within the preview modal and load the next PDF in the list.

This functionality has introduced an issue where a gray screen appears within the controller at various locations within the collection. It may occur on the 3rd item, 50th, or 161st item; this error is very inconsistent and difficult to reproduce.

Apple's Gray Screen of Death

When the gray screen appears in the modal the ability to swipe left or right is no longer available. After dismissing the modal and re-selecting the PDF from the table source, it loads without issue. This experience reinforces our theory that this gray screen appears due to memory management issues.

What is the proper way to manage memory within a QLPreviewController regardless of size of the data source? Are there code examples which demonstrate how to use a QLPreviewController with multiple items in its data source?

What does the memory usage of your app look like when this happens? Is it higher than when you started browsing the PDFs? If this is due to memory management issues you'll get a LowMemory diagnostic report synced over to your Mac; it will show which processes are using memory. If quicklookd is using large amounts of RAM it might be Apple's fault; if your app is then you should look into your memory usage.Thomas Deniau
@ThomasDeniau quicklookd is definitely the process which consumes the most memory. It continually grows and only shrinks after its crashes which is when the gray screen appears. We added code to garbage collect in the DidReceiveMemoryWarning method, however, it does not reduce the memory. Do you know the proper code to reduce the memory usage of the quicklookd process?Shawn Roser
You can't. quicklookd is code that is completely managed by Apple. You should file a bug report and attach the LowMemory logs you have (and note the number of PDFs you're trying to display and their size).Thomas Deniau
@ThomasDeniau We submitted a bug report to Apple early this afternoon. I will report back with their answer. Thank you for your assistance.Shawn Roser
@ShawnRoser Did you figure out any solution yet?Master AgentX