dio
dio copied to clipboard
Downloading many files keeps increasing memory usage and can eventually crash application
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](https://user-images.githubusercontent.com/98470469/180241066-b5a8d129-5671-44bb-9808-3d9556dc32fc.png)
![Screen Shot 2022-07-21 at 9 48 27 AM](https://user-images.githubusercontent.com/98470469/180241157-1b6668df-707a-49bd-8702-8e511a0afcad.png)
After tapping the button 3 times (60 files downloaded):
![Screen Shot 2022-07-21 at 9 50 52 AM](https://user-images.githubusercontent.com/98470469/180241339-d7635079-0140-426d-9e7c-ccc3acf475af.png)
![Screen Shot 2022-07-21 at 9 49 55 AM](https://user-images.githubusercontent.com/98470469/180241390-316935ca-3580-4806-b8d1-b207922e559d.png)
This issue maybe caused by Dart http https://github.com/flutter/flutter/issues/108513