Hi,
We are facing a memory leak issue caused by NSURLSession when it downloads data with https protocol via proxy server. Minimum code like below reproduces large amount of memory leak on a few call of startDownload. This happens on device or simulator with iOS10.2. iOS9.3 causes the similar memory leaks, but the leak objects are NetworkProxy related ones only.
- (void)startDownload {
NSURLSessionConfiguration *urlSessionCfg = [NSURLSessionConfiguration defaultSessionConfiguration];
_session = [NSURLSession sessionWithConfiguration:urlSessionCfg delegate:self delegateQueue:nil];
NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.apple.com"]
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:100];
NSURLSessionDataTask *task = [_session dataTaskWithRequest:req];
[task resume];
}
- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task
didCompleteWithError:(nullable NSError *)error {
[_session invalidateAndCancel];
_session = nil;
}
We need private session objects, not shared one, changing session config and delegate.
What is the status of this issue? Are there any workarounds to avoid this leak?
Thank you,