dio icon indicating copy to clipboard operation
dio copied to clipboard

Downloading many files keeps increasing memory usage and can eventually crash application

Open cal-g opened this issue 1 year ago • 1 comments

New Issue Checklist

  • [x] I have searched for a similar issue in the project and found none

Issue Info

Info Value
Platform Name flutter
Platform Version Flutter 3.0.5
Dio Version 4.0.6
Android Studio / Xcode Version Xcode 13.4
Repro rate all the time (100%)
Repro with our demo prj Yes, it also happens with download example.
Demo project link Demo gist

Issue Description and Steps

When using the dio.download api for downloading many small files the memory keeps increasing. The memory does reduce a bit , about 10%, after a while but stays high for the most part. The memory can quickly reach to very high levels if downloading a lot of images (200+) and the application will eventually crash for low RAM devices such as an iPhone8 which has only 2GB RAM.

Dart Observatory and Memory Tab (Flutter DevTools) screenshots :

At the beginning of app start (Before downloading file) :

Screen Shot 2022-07-21 at 9 47 55 AM Screen Shot 2022-07-21 at 9 48 27 AM

After tapping the button 3 times (60 files downloaded):

Screen Shot 2022-07-21 at 9 50 52 AM Screen Shot 2022-07-21 at 9 49 55 AM

cal-g avatar Jul 21 '22 14:07 cal-g

This issue maybe caused by Dart http https://github.com/flutter/flutter/issues/108513

liqping avatar Jul 29 '22 01:07 liqping