Your workflow is unique 👨‍💻 -  tell us how you use Dropbox here.

Forum Discussion

Ryan F.17's avatar
Ryan F.17
New member | Level 1
10 years ago

Getting OutOfMemoryException when downloading

Hello,

I wrote a quick console app using Dropbox.NET with the intent of downloading particular files or folders from Dropbox (for archival purposes, etc...there are multiple reasons).

However, I quickly ran into an issue when it tried to download a 1GB file. I receive an OutOfMemoryException. Here is the code that I use:

---------------

private async Task DownloadFile(string dropboxPath, string targetPath) {
    using (var response = await _dbx.Files.DownloadAsync(dropboxPath)) {
        using (var source = await response.GetContentAsStreamAsync()) {
            using (var target = File.Create(targetPath)) {
                await source.CopyToAsync(target);
            }
        }
    }
}

---------------

This code does work for smaller files, and I know my system itself is not out of memory (have over 8 GB still available). Am I doing something wrong?

Please advise...thanks!

Ryan

3 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

    Thanks for the report Ryan! This looks like a bug in the SDK. We're looking into it.

  • Ryan F.17's avatar
    Ryan F.17
    New member | Level 1
    10 years ago

    The fix did indeed take care of the problem. Thanks so much for such a speedy resolution!

About Dropbox API Support and Feedback

Node avatar for Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.

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!