Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MultiFlutterEngine on iOS consumes a lot of memory #79023

@icespring

Description

@icespring

Steps to Reproduce

  1. use sample code for multiple flutters on iOS here : https://github.com/flutter/samples/tree/master/add_to_app/multiple_flutters
  2. run the sample code on iOS real devices with flutter release mode build
  3. push "next" button, see the memory monitor

I created about 5 FluttterViewControllers,the memory is up to 200M+
image

But as the "Multiple Flutter screens or views" page note that

The 2.0.0 Flutter release drastically reduces the memory footprint of additional Flutter engines from ~19MB on Android and ~13MB on iOS, to ~180kB on Android and iOS. This ~99% fixed cost reduction allows the multiple Flutters pattern to be used more liberally in your add-to-app integration.

Am I wrong with something? I expected create FlutterEngine would save much memory.

finally, with flutter doctor

[✓] Flutter (Channel stable, 2.0.3, on Mac OS X 10.15.6 19G2021 darwin-x64, locale zh-Hans-CN)
    • Flutter version 2.0.3 at /Users/icespring/bin/flutter
    • Framework revision 4d7946a68d (6 days ago), 2021-03-18 17:24:33 -0700
    • Engine revision 3459eb2436
    • Dart version 2.12.2
    • 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/icespring/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    ! CocoaPods 1.9.3 out of date (1.10.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 4.1)
    • 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 1.8.0_242-release-1644-b3-6915495)

[✓] Android Studio
    • Android Studio at /Users/icespring/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7136282/Android Studio
      Preview.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.8+10-b944.6842174)

[✓] VS Code (version 1.52.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.18.1

[✓] Connected device (4 available)
    • ONEPLUS A6013 (mobile)       • 9ab75e76                             • android-arm64  • Android 10 (API 29)
    • “icespring”的 iPhone (mobile) • 00008020-000565163A79002E            • ios            • iOS 14.0
    • iPhone 12 Pro Max (mobile)   • 0B485DD1-7E98-439F-B96F-84CCA087C6A0 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-4
      (simulator)
    • Chrome (web)                 • chrome                               • web-javascript • Google Chrome 89.0.4389.90

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: existing-appsIntegration with existing apps via the add-to-app flowc: performanceRelates to speed or footprint issues (see "perf:" labels)engineflutter/engine related. See also e: labels.found in release: 2.0Found to occur in 2.0has reproducible stepsThe issue has been confirmed reproducible and is ready to work onperf: memoryPerformance issues related to memoryplatform-iosiOS applications specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions