As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
why does the memory usage grow so large during file download?
k
kallayb
started a topic
almost 9 years ago
I am using the KCSFileStore to upload and download video files. When downloading I notice the memory steadily grows and will often put enough pressure to get my app closed.
When I begin the download the app is consuming 30MB but after downloading an 80MB file the usage spikes to 420MB and stays there. I have tried using both downloadData and downloadFile and have observed identical memory usage for both calls. I have also tried a nil progressBlock which did not have an impact either.
Are you certain that you are downloading a single file, i.e. you are not downloadFileByQuery, which could get multiple files? Also, what are you doing with the file after download - are you passing it to a media player of some sort, where decoding could be happening? Could you try with a different, non video file? Finally, are you certain that your app isn't doing anything else besides the download?
How are you sampling the memory - you mentioned the usage spiking *after* the download. How does it look *during*?
k
kallayb
said
almost 9 years ago
Hi Ivan,
Thanks for the reply.
**Are you certain that you are downloading a single file, i.e. you are not downloadFileByQuery, which could get multiple files? **
I am using the file Id to retrieve and I have inspected the NSArray that is returned to ensure it is just the single file requested.
**Also, what are you doing with the file after download - are you passing it to a media player of some sort, where decoding could be happening? **
After the file download I am copying it locally out of the cache dir. However, after the download is complete and the completion block executes, the memory usage ceases to grow.
**Could you try with a different, non video file? **
I can but it will take some time to retrofit my code to support this.
**Finally, are you certain that your app isn't doing anything else besides the download? How are you sampling the memory - you mentioned the usage spiking after the download. How does it look during?
**
Sorry I could have been more clear here. I am running the app through Xcode on an external device (an iPad) and monitoring the memory footprint using the information Xcode provides. As the download proceeds the memory continues to grow until the completion block is executed at which point it stabilizes so I don't believe anything after the download is at fault. In my testing I am only requesting the file download and not executing anything else within the app so I am fairly certain that the memory growth is a result of the download.
I
Ivan Stoyanov
said
almost 9 years ago
What version of iOS is running on the device? If it is 8, can you try with 7, maybe in the simulator?
Your logic to narrow it down to the library makes sense to me, but to isolate it even further, you can create a trivial app that all it does is download this one file. Then also try a different file, since the OS could on theory be doing something strange behind the scenes with your video encoding.
k
kallayb
said
almost 9 years ago
This is an app running iOS 8.
I created a very simple test that does nothing but log in and pull the file and then ran the test using the iOS 8 simulator and then the iOS 7.1 simulator.
The memory issue exists for this simple test using the iOS 8 simulator but is not present using iOS 7.1, so it seems there is an issue with this code and iOS 8.
Please let me know if I can provide any other information to move this along.
k
kallayb
said
almost 9 years ago
**Update**: I decided to try and implement the REST API as a way of getting beyond the memory issue but noticed the exact same problem when I downloaded the file using NSURLSessionDownloadTask directly to pull from the _downloadURL.
After some work I was able to get this scenario running in Instruments so I could profile the memory usage with more granularity only to find that the memory footprint is stable and does not grow out of control as it does when running through xcode. My conclusion is that this is a bug in xcode 6.0.1 and is really a non-issue as far as Kinvey is concerned.
Determining this using Instruments was difficult as it crashes frequently when Kinvey calls are made, my experience is limited using Instruments so if there is some setup I am missing that makes this stable with the KinveyKit please let me know.
I
Ivan Stoyanov
said
almost 9 years ago
Phew. Thank you, I really appreciate you digging that deep.
kallayb
When I begin the download the app is consuming 30MB but after downloading an 80MB file the usage spikes to 420MB and stays there. I have tried using both downloadData and downloadFile and have observed identical memory usage for both calls. I have also tried a nil progressBlock which did not have an impact either.
Am I missing something? I'm using Xcode 6.0.1
I really appreciate any insight.