Possible memory leak?

I’m using the iOS SDK (8.1.2 via SPM) and, at least in the simulator, it looks like the memory continues to grow as I view documents. I tried to strip out all my custom code, and just doing the following snippet still causes memory to grow:

let docController = PTDocumentController()
let navController = UINavigationController(rootViewController: docController)
let fileURL = URL(string: downloadLink)!
docController.openDocument(with: fileURL)
presenter.present(navController, animated: true, completion: nil)

I’m accessing a file from AWS instead of locally. That “presenter” variable is just one of my UIViewController classes. The PDF opens and displays just fine, but when I leave the screen and come back to view a new document, I see the memory used is growing pretty significantly.

In my custom class, derived from PTDocumentController, I did try overriding viewWillDissapear and manually call closeDocument, which seems to help a LOT, but the memory still grows pretty quickly.

Any help would be greatly appreciated!! Thanks.


Thank you for getting in touch with us about this.
We are investigating this behaviour and we will let you know once we have more information.


Thank you for reporting this.
We discovered a situation where the PTDocumentController was not being deallocated when removed from the view which seems to be the likely culprit.
This issue only occurs when running on iOS 14.
We’ve implemented a fix which is now available in our stable nightly builds as of 2021-03-24:

This fix will also be in our future releases.
If you prefer to wait for an official release, a workaround would be to call the following inside your PTDocumentController subclass’ viewWillDisappear:

override func viewWillDisappear(_ animated: Bool) {
self.moreItemsButtonItem.menu = nil // set this property to nil