PHCachedImageManager not deallocated

Originator:andreas.guenther
Number:rdar://FB7706187 Date Originated:May 18, 2020 at 2:03 PM
Status:Open Resolved:
Product:PhotoKit Product Version:13.4
Classification:Incorrect/Unexpected Behavior Reproducible:Always
 
We created an app that opens a second screen showing a Collection view (PhotosViewController) displaying images of the phones photo library
We use the recommended PHCachedImageManager to retrieve the images from Photos library (See attached project)

We saw that when opening and closing the collection view multiple times the memory usage of the app grows. This eventually leads to the app being killed by the OS because it uses too much memory.

Our investigations showed us that the PHCachedImageManager referenced in the collection view is still in memory even though the  PhotosViewController is already deallocated.

## Steps to reproducing using the apache Project

* Grant photos permission to the app (app may be restarted)

* tap “show photos”
* tap back to close the
* open “Debug memory graph” in Xcode
* filter for “PHCachedImageManager”

## Current behavior
PHCachedImageManager is NOT allocated although PhotosViewController is already deallocated which is the only instance holding a reference

## Expected behavior
PHCachedImageManager is still allocated although PhotosViewController is already deallocated which is the only instance holding a reference

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!