这个AFNetworking代码片段会泄漏内存,但为什么呢?

时间:2013-11-05 06:11:47

标签: ios objective-c memory-leaks afnetworking-2

以下代码上传了一些JSON数据,但是像疯了一样泄漏内存,我不知道为什么。我正在使用AFNetworking 2.0和ARC与XCode 5.0.1。根据乐器的说法,有许多AFRequestOperations生活,比我预期的要多。但ARC不应该自动释放它们吗?

NSData *binData = [NSData dataWithBytes:s_print_buff length:(cur_output - s_print_buff) ];

NSURL *url = [NSURL URLWithString:@"http://SOMEIP:SOMEPORT/upload"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json" forHTTPHeaderField:@"content-type"];
[request setValue:[NSString stringWithFormat:@"%d", [binData length]] forHTTPHeaderField:@"content-length"];
[request setHTTPBody:binData];

AFHTTPRequestOperation *op= [[AFHTTPRequestOperation alloc] initWithRequest:request];
op.responseSerializer = [AFJSONResponseSerializer serializer];

[[NSOperationQueue mainQueue] addOperation:op];

0 个答案:

没有答案