Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Fixed memory leak in NSURLSession handling #2794

Closed
wants to merge 2 commits into from

Conversation

sound-eng
Copy link
Contributor

No description provided.

@@ -316,7 +316,8 @@ + (void)load {
7) If the current class implementation of `resume` is not equal to the super class implementation of `resume` AND the current implementation of `resume` is not equal to the original implementation of `af_resume`, THEN swizzle the methods
8) Set the current class to the super class, and repeat steps 3-8
*/
NSURLSessionDataTask *localDataTask = [[NSURLSession sessionWithConfiguration:nil] dataTaskWithURL:nil];
NSURLSession * session = [NSURLSession sessionWithConfiguration:nil];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+ (NSURLSession * nonnull)sessionWithConfiguration:(NSURLSessionConfiguration * nonnull)configuration

This method actually requires an argument according to iOS 9 sdk nullability

@phoney
Copy link

phoney commented Sep 25, 2015

This is a real bug that should be fixed. Apple's docs say

"The session object keeps a strong reference to the delegate until your app explicitly invalidates the session. If you do not invalidate the session, your app leaks memory."

alistra's comments are correct but the fix is trivial. Just add the default configuration when creating the session. I believe that @kcharwood wrote this code so maybe you want to fix this if @olegnaumenko isn't responding.

@kcharwood
Copy link
Contributor

I'll take a look at this soon. Thanks @phoney

@kcharwood kcharwood added this to the 2.6.2 milestone Oct 21, 2015
kcharwood added a commit that referenced this pull request Oct 21, 2015
@kcharwood
Copy link
Contributor

Rebased with some additional changes in 09f6cc1

kcharwood added a commit that referenced this pull request Oct 21, 2015
@kcharwood
Copy link
Contributor

Pushed to master in 09f6cc1

Pushed to 3.0.0 with b2c449c

Thanks everyone! 🍻

@kcharwood kcharwood closed this Oct 21, 2015
@kcharwood kcharwood changed the title fix memory leak in NSURLSession handling Fixed memory leak in NSURLSession handling Nov 3, 2015
@kcharwood kcharwood added the fixed label Nov 3, 2015
sergiou87 pushed a commit to plexinc/AFNetworking that referenced this pull request Dec 12, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants