every time i make a request to my web server via NSURLSession/Connection it leaks! To be honest it is not much but if you have to make a couple hundreds or thousands of calls this gets nasty.
I have been on this for about a week now. I have tried everything. NO cache , little cache, setting everything on nil after the call is done(which is unnecessary), using datatask for sessions or just connection with requests. Every time i get a little more memory allocated and i have not found a way to solve this problem.
So i set up a little testApp:
#import "ViewController.h"
@interface ViewController ()
@property NSString *param;
@property NSURL * url;
@property NSURLConnection *test;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.param = [NSString stringWithFormat:@"hi"];
self.url = [[NSURL alloc]initWithString:@"http://127.0.0.1/xmlfile.php"];
for (int i = 0; i<20000; i++){
[self connect:self.param url:self.url];
}
NSLog(@"I AM DONE!");
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSData *)connect:(NSString*)param url:(NSURL*)url{
self.test = [[NSURLConnection alloc]initWithRequest:nil delegate:self];
[[NSURLCache sharedURLCache] removeAllCachedResponses];
return nil;
}
@end
i would love to add images of the memory usage but i am too new. so just go here: 5k:iterations http://i59.tinypic.com/123tts2.png 20k: http://i59.tinypic.com/1zzqsrk.png
I have heard that this could be a problem with ios8.
Please help!
I am open for everything and would be happy if someone could prove me wrong and show me the right way. Thanks a bunch