Forum Discussion

James Z.3's avatar
James Z.3
New member | Level 1
10 years ago

[Swifty] File download memory management

I noticed that for every GB I download to local file system via  client.files.download, the app's memory usage increase by that amount. I imagine the Dropbox client doesn't keep the file in memory after it downloads the file, so it must be something that the rest of my app is doing. Can you confirm? Thanks.

8 Replies

Replies have been turned off for this discussion
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    10 years ago

    Hi James, that certainly would be unexpected and non-ideal, and I'm not aware of any other such reports. If it doesn't seem to be something your app is doing though, we'd be happy to look into it. The version number of the SDK you're using and the relevant code snippet(s) would be useful in that case.

  • James Z.3's avatar
    James Z.3
    New member | Level 1
    10 years ago

    Hi Greg, thanks for the quick response. Here's a gist of what the app tries to do. It downloads an mp3 file and tries to extract its metadata. I'm on 2.0.2 right now. Thanks!

  • sigrem's avatar
    sigrem
    New member | Level 1
    10 years ago

    Hi, We are seeing a similar issue when downloading files from Dropbox using Swifty Dropbox. The memory usage increases gradually to almost 2/3 of the file size by around 1 MB/sec. For example for a file of size 320 MB the memory usage goes from 40 MB (when download started) to 240 MB and stays there until the download is finished:

        let destination : (NSURL, NSHTTPURLResponse) -> NSURL = { temporaryURL, response in

            let localUrl = NSURL(fileURLWithPath: self.localPath)

            return localUrl

        }

        if let client = Dropbox.authorizedClient {

            client.files.download(path: dbPath, destination: destination).response

                {

                    response, error in

                    if let (metadata, url) = response {

                        if error != nil {

                            NSlog("Dropbox download failed. \(error!.description)", .Error)

                        }

                        else {

                            NSlog("Dropbox file downloaded.")

                        }

                    }

            }

        }

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    10 years ago

    Thanks for the additional information sigrem! I don't have an update on this right now, but I'll follow up on this thread when I do.

  • sunil t.'s avatar
    sunil t.
    New member | Level 1
    10 years ago

    I also faced the same problem when download from Dropbox the file size increases

  • Hi Sunil, we looked into this issue on our end and were not able to reproduce it, even in the case of large file downloads. SwiftyDropbox does not handle any memory management -- memory is managed by a third-party networking library, AlamoFire.

    You might also want to double check your memory usage levels. Xcode's simulator is known to be unreliable about showing accurate memory usage levels. I would be sure to test memory usage on an actual device as well.

    Additionally, we will be distributing a new version of SwiftyDropbox in the next week. I would encourage you to adopt the new version when it is released, as it might address the issue for you as well.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!