Afnetworking: Possible memory leak in AFURLSessionManager

Created on 22 Oct 2013  路  2Comments  路  Source: AFNetworking/AFNetworking

I'm using AFNetworking in an iOS app that I'm working on and when profiling it, I noticed that there were several of my custom AFURLSessionManager subclass objects getting leaked. After looking around a bit, I think I may have found the problem.

AFURLSessionManager retains its NSURLSession object, while also setting itself as the NSURLSession's delegate. Because NSURLSession holds a strong reference to its delegate, this can lead to a retain cycle.

If you can confirm that this is an issue, I'd be glad to look into fixing it.
Thanks!

Most helpful comment

This is known and documented behavior. When you're finished with a session, call invalidateSessionCancelingTasks:. This is not an issue for most apps, which keep a single session for the lifetime of the application.

All 2 comments

This is known and documented behavior. When you're finished with a session, call invalidateSessionCancelingTasks:. This is not an issue for most apps, which keep a single session for the lifetime of the application.

Where is it best to place the call to invalidateSessionCancelingTasks ?

Was this page helpful?
0 / 5 - 0 ratings