Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dio post formData file and cost memory to large #1899

Closed
XutongGithub opened this issue Jul 21, 2023 · 8 comments
Closed

dio post formData file and cost memory to large #1899

XutongGithub opened this issue Jul 21, 2023 · 8 comments

Comments

@XutongGithub
Copy link

Package

dio

Version

^4.0.0

Output of flutter doctor -v

[✓] Flutter (Channel stable, 3.3.0, on macOS 12.6.1 21G217 darwin-x64, locale en-CN)
    • Flutter version 3.3.0 on channel stable at /Users/fjrb/Desktop/FZDev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ffccd96b62 (11 months ago), 2022-08-29 17:28:57 -0700
    • Engine revision 5e9e0e0aa8
    • Dart version 2.18.0
    • DevTools version 2.15.0
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/fjrb/Library/Android/sdk
    • Platform android-33, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 14.1)
    • Xcode at /Applications/Xcode14.app/Contents/Developer
    • Build 14B47b
    ! CocoaPods 1.10.2 out of date (1.11.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

Dart Version

2.18.0

Steps to Reproduce

var response = await _dio.post(signedUrl, cancelToken: _cancelToken, data: formData);

Expected Result

cost large memory
上传大的视频或者文件,消耗大内存,并没有释放。

Actual Result

不占用大内存,如何及时释放内存

@XutongGithub XutongGithub added h: need triage This issue needs to be categorized s: bug Something isn't working labels Jul 21, 2023
@AlexV525 AlexV525 added h: need more info Further information is requested i: outdated and removed h: need triage This issue needs to be categorized s: bug Something isn't working labels Jul 21, 2023
@AlexV525
Copy link
Member

Consider upgrade to the latest version and provide a minimal reproducible example.

@XutongGithub

This comment was marked as off-topic.

@XutongGithub
Copy link
Author

I update dio to 5.3.0 and cause another problem

SImple minimal reproducible example.
var response = await _dio.get('authinfo');

Expected Result
response is null

DioException [unknown]: null

@AlexV525
Copy link
Member

This is not a reproducible example. Please see the migration guide if acquired.

@Lionyy
Copy link

Lionyy commented Aug 14, 2023

final mpFile = await m_dio.MultipartFile.fromFile(realLocalPath, filename: encodeFileName);
final formData = m_dio.FormData.fromMap({'trim-upload-file': mpFile});
MultipartFile会直接把整个文件读到内存中。

@XutongGithub

This comment was marked as spam.

@AlexV525
Copy link
Member

final mpFile = await m_dio.MultipartFile.fromFile(realLocalPath, filename: encodeFileName); final formData = m_dio.FormData.fromMap({'trim-upload-file': mpFile}); MultipartFile会直接把整个文件读到内存中。

提供细节?通过什么方式判断整个文件读进了内存中?

@AlexV525 AlexV525 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 24, 2023
@AlexV525 AlexV525 added i: no useful information and removed h: need more info Further information is requested i: outdated labels Oct 24, 2023
@XutongGithub
Copy link
Author

XutongGithub commented Oct 24, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants