Hi,
I'm developing an uploader of with NSOperations. I got it to work with NSURLSessionConfiguration using background config, but it is buggy beacuse some of the memory leak that I'm experiencing with NSOperation.
my code is kind of big to post it here but If you want I can do that. I'll try to explain overall what I'm doing.
I have a UploadOperation that depends on a ConvertFile Operation. I have a NSOperationQueue configure like this:
self.uploadQueue = [NSOperationQueue new];
self.uploadQueue.name = @"Upload Process Queue";
self.uploadQueue.maxConcurrentOperationCount = 4;
self.uploadQueue.qualityOfService = NSOperationQualityOfServiceUserInitiated;
The upload only starts after the file is successfuly converted... OK...
Now the uploadOperation kicks in.. it reads to a NSData like so NSData* data = [[NSData alloc] initWithContentsOfFile:self.pathFile];
and the I create the request ... and add it to the background NSURLSessionUploadTask and the even clear the nsdata, the request and the body from the main() of the upload uperation.. but this does not change a thing.
...
[request setHTTPBody:body];
self.uploadDataTask = [self.sessionURLBackground uploadTaskWithStreamedRequest:request];
[self.uploadDataTask resume];
data = nil;
request = nil;
body = nil;
At this time the memory jumps because the files are Images and Movies... and each time a Upload operation kicks in the memory only grows. the Operation finishes and the memory isn't released... which leads, some times to the bug... It fails on URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error with an error of Error Domain=NSURLErrorDomain Code=-997 Lost connection to background transfer service...
This only happens sometimes when I add like 3 or 4 videos and the memory gets over 60 MB... and if one upload operation fails I create a new NSOperation to upload the same file and the memory still only rises... never decreases...
Is there a trick to force clear all finished NSOperations?