Untraceable AFNetworking memory leak
<p><strong>TL;DR : Clone and check leak yourself <a href="https://github.com/JakubMazur/SO41343532/" rel="nofollow noreferrer">https://github.com/JakubMazur/SO41343532/</a></strong></p>

<p>I have a one class that handle all my networking. It's called <code>ResponseOrganizer</code> and in there I have a class method:</p>

<pre><code>+ (void)getSth:(void (^)(NSURLSessionDataTask *operation, NSArray *locales, id plainObject))success failure:(void (^)(NSURLSessionDataTask *operation, NSError *error))failure {

    Connection *connection = [Connection new];
    connection.urlString = @"http://sample-file.bazadanni.com/download/txt/json/sample.json";
    connection.requestMethodType = GET;

    [connection fireWithSuccess:^(NSURLSessionDataTask *operation, NSArray *returnArray, id originalResponse) {
        success(operation, returnArray, originalResponse);
    } failure:^(NSURLSessionDataTask *operation, NSError *error) {
        failure(operation, error);
    }];
}
</code></pre>

<p>Where <code>Connection</code> is a single my internal connection object:</p>

<p>Here is the implementation:</p>

<pre><code>#import "Connection.h"

@interface Connection()
@property (weak,nonatomic) AFHTTPSessionManager *manager;
@end

@implementation Connection

#pragma mark - Connection groundwork

-(void)fireWithSuccess:(void (^)(NSURLSessionDataTask *operation, NSArray* returnArray, id originalResponse))success failure:(void (^)(NSURLSessionDataTask *operation, NSError *error))failure {

    self.manager = [AFHTTPSessionManager manager];
    [self.manager urlString:self.urlString withMethod:self.requestMethodType parameters:self.paramaters success:^(NSURLSessionDataTask *operation, id responseObject) {
        success(operation,@[responseObject],nil);
    } failure:^(NSURLSessionDataTask *operation, NSError *error) {
        failure(operation,error);
    }];
}

@end
</code></pre>

<p>And I have a category calling right method inside <code>AFNetworking</code>. To simplify it look like this:</p>

<pre><code>-(void)urlString:(NSString*)urlString withMethod:(RequestMethodType)method parameters:(NSDictionary*)parameters success:(void (^)(NSURLSessionDataTask *operation, id responseObject))success failure:(void (^)(NSURLSessionDataTask *operation, NSError *error))failure {
    switch (method) {
        case GET: {
            [self getWithURLString:urlString parameters:parameters success:^(NSURLSessionDataTask *operation, id responseObject) {
                success(operation,responseObject);
            } failure:^(NSURLSessionDataTask *operation, NSError *error) {
                failure(operation,error);
            }];
            break;
        }
}
</code></pre>

<p>And when I want to make request for example in my ViewController I make it like this:</p>

<pre><code>[ResponseOrginizer getSth:^(NSURLSessionDataTask *operation, NSArray *locales, id plainObject) {

} failure:^(NSURLSessionDataTask *operation, NSError *error) {

}];
</code></pre>

<p>And when I run it in instrument I'm always getting:</p>

<p><a href="https://i.stack.imgur.com/EfIWB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EfIWB.png" alt="enter image description here"></a></p>

<p>And it here doesn't matter it will land on success/failure block, it always cause a leak. I extract everything from this and put it on github as simple as possible. Github link: 
<a href="https://github.com/JakubMazur/SO41343532/" rel="nofollow noreferrer">https://github.com/JakubMazur/SO41343532/</a></p>