The URLSession object in CKURLRequest was not calling finishTasksAndInvalidate(), which causes a memory leak. URLSession holds a strong reference to the delegate, and if it's not cleaned up then each session instance stays around forever. From the docs:
Important
The session object keeps a strong reference to the delegate until your app exits or explicitly invalidates the session. If you don’t invalidate the session, your app leaks memory until it exits.
Operations had retain cycles in their completion closures (missing [weak self] capture list)
URLSession
object inCKURLRequest
was not callingfinishTasksAndInvalidate()
, which causes a memory leak.URLSession
holds a strong reference to the delegate, and if it's not cleaned up then each session instance stays around forever. From the docs:[weak self]
capture list)