-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GTMSessionFetcher seems to be accumulating data, even though a a download path is specified #60
Comments
As long as
|
Thank you for the help and quick reply. I'm definitely setting the destinationFileURL before calling beginFetchWithCompletionHandler: and I verified destinationFileURL is not nil before the beginFetchWithCompletionHandler call. In addition, I tried setting the accumulatedDataBlock and it is not being called. So, as far as I can tell, I'm using it correctly. However, the memory definitely continuously increases as it downloads the file. So, I'm puzzled currently. I'll continue investigating. Thanks again. |
Also, if I don't set the destinationFileURL and I add the accumulatedDataBlock, then it will call the accumulatedDataBlock, as expected, for that case. |
I'd suggest looking in Instruments to see where the memory growth is occurring; I don't see anything in the fetcher itself should be hogging memory as a result of a download-to-file, but of course there could be a bug triggered somehow. Some StackOverflow articles hint at folks seeing memory pressure from NSURLSessionDownloadTask, although it appears some of that was Xcode/debugger related and since fixed. Instruments should show where allocated memory is lurking. |
I will look into that to see what I find. Thanks again for the help. |
I looked into this using Instruments and, from what I can tell, it does not show a memory issue. No leaks are shown and when looking at Memory Allocation, it stays steady around 60MiB. When setting Generations at about every 5% download (for a 600 MiB file) the Growth is in the KiB range. I tried switching to using beginFetchWithDelegate:didFinishSelector: and this still showed the issue when debugging. In addition, I also tried adding my own accumulatedBlock handler and writing the NSData on my own within the block, but even with this, the memory issue was still there. All very bizarre. Continuing investigation, but just wanted to update with the current status. |
When you run with the debugger in Xcode, do you have NSZombie or other memory diagnostics enabled? |
No. NSZombie nor are any other memory diagnostics enabled. I'm just using Xcode's built-in memory tool. Nothing special. I did try using Zombie from Instruments. For comparison:
I thought maybe it was just an issue with the Debugger, but when running the App, without the debugger, it still runs out of memory. Sometimes while downloading, it will end up timing out instead and return with the following error in the completionHandler: |
I downloaded the DriveSample App from https://github.com/google/google-api-objectivec-client/tree/master/Examples to see if the issue replicates outside of our App. Unfortunately the DriveSample only support Mac, but I updated the code to follow the same logic that is being used in our app. With the same code, I found the memory issue does not exist in the Mac Sample App, while it does exist in our App. Code copied below. Next I am going to look into: Updating the sample App to Support iOS to see if the issue occurs Sample Mac GoogleDrive App (Modiefied to download file instead of thumbnail): No memory issue (void)updateThumbnailImage {
// Makes sure it doesn't download the file multiple times, since the method is called when the UI is updated, in the default sample app behavior
} Our App: Memory issue - Modified to match Sample App logic NSString *fileName = file.fileTitle; // Create the block that will handle updating the progress of the file // hook up the progress and completion handlers |
We created a new basic iOS App with sign-in and file download, following the sample Mac app implementation. We see the same memory behavior. Running in Simulator: Does not show a memory issue. Regardless of how running, large files do not seem to download completely:
Error returned:
Currently out of ideas. |
Can you post your sample so we can be sure we're comparing the same things? |
Hi, Sorry for the delay. I did some additional investigation and found that the results vary depending on the iOS version on a physical device. To summarize findings:
iPad - 8.4.1 - No Connection Timeout, No Memory Issue Sample App Notes:
Result: |
Any thoughts on this? For now, we are just preventing large file downloads on the affected iOS versions. Thank you |
We are using the GTMSessionFetcher (1.1.6) in order to download files from Google Drive. We are having memory issues with large files.
Previously we were using GTMFetcher, but we updated our libraries. In using the session fetcher, we are specifying a DownloadProgressBlock, DestinationFileURL and completion handler, like the following:
fetcher = [weakSelf.driveService.fetcherService fetcherWithURLString:url];
[fetcher setDownloadProgressBlock:downloadProgressHandler];
NSURL *myURL = [NSURL fileURLWithPath:fullpath];
[fetcher setDestinationFileURL:myURL];
[fetcher beginFetchWithCompletionHandler:completionHandler];
Everything downloads okay, but the memory increases and, for large files, runs out of memory.
Previously, we had the following, which did not have the memory problem:
fetcher = [weakSelf.driveService.fetcherService fetcherWithURLString:url];
[fetcher setReceivedDataBlock:receivedData]; // setReceivedDataBlock is no longer available in the updated library
[fetcher setDownloadPath:fullpath]; // setDownloadPath is no longer available in the updated library
[fetcher beginFetchWithCompletionHandler:completionHandler];
Is there some additional configuration needed, so that data is not accumulated? I tried [fetcher setAccumlatedDataBlock:nil], but that seemed to have no effect.
Thank you!
-Kevin
The text was updated successfully, but these errors were encountered: