AFNetworking 2 POST Memory Leak

393 views Asked by At

I used AFNetwoking but the simple AFHTTPRequestOperationManager's POST:parameters:success:failure got a memory leak:

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager POST:@"https://my.url.com"   
   parameters:@{@"key":@"value"}
      success:^(AFHTTPRequestOperation *operation, id responseObject)
      {
         NSLog(@"Sent!");
      } 
      failure:^(AFHTTPRequestOperation *operation, NSError *error)
      {
         NSLog(@"failed!");
      }];

Here are the relevant screenshots:

enter image description here

Expanded - CFURLCredential:

Expanded - NSCFString

I'm using ARC. I have a method & inside that method is the request above.
It is automatically called when the view controller appears -- viewDidAppear.

Every time the method is called the memory leak happens. I thought it was the dictionary (not the example above) that I am passing so I removed my dictionary parameter and changed to a simple @{"key":@"value"} just to be safe. Then, the leak happened again.

Before, I encountered a memory leak because the method was being called in the background, so I tried to put a button and link that to an IBAction to ensure that the method is triggered properly:

- (IBAction)sendRequest:(id)sender
{
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

   [manager POST:@"https://my.url.com"   
      parameters:@{@"key":@"value"}
         success:^(AFHTTPRequestOperation *operation, id responseObject)
         {
            NSLog(@"Sent!");
         } 
         failure:^(AFHTTPRequestOperation *operation, NSError *error)
         {
            NSLog(@"failed!");
        }];
}

Still, every time I press the button and the request finishes, the leak always occurs.
By the way, I'm testing it on an iPhone4 iOS 7.

0

There are 0 answers