URLSessionUploadTask memory usage

Hi all,

I'm working on a FileProvider extension and currently using a library to do networking. However, my app extension gets killed when uploading files because they are loaded into memory.

Now, in WWDC 2017 session 243 (FileProvider Enhancements) it is mentioned that an URLSessionDownloadTask and URLSessionUploadTask are the way to go because they don't use memory allocations. Is that a guarantee? Or does it differ per instantiation method (InputStream, Data, fileURL)?

Or does it differ per instantiation method (InputStream, Data, fileURL)?

Yes. If you create your upload task with a Data value, you have to read the entire file into memory to build that Data value, so you don’t win anything. The other options allow the upload task to stream the file’s content, which avoids the need to read it all into memory at once.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

URLSessionUploadTask memory usage
 
 
Q