-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
Steps to reproduce
- Clone the example at https://github.com/kekland/flutter_gpu_memory_leak and run
- The slider on the bottom controls the number of vertices being allocated and subsequently rendered. The change to this value triggers vertex buffer re-allocation.
- To get a memory leak, drag this slider back-and-forth for some time. Frame drops are expected, since the slider's max value is somewhere around a million.
Expected results
No memory leak on Android. The exact same code on macOS seems to not leak anything
Actual results
macOS: Apple Silicon, M3 Pro (18GB), macOS 15.0.1
On macOS there doesn't seem to be a memory leak. After a minute-long run, the memory usage as indicated in the Activity monitor is similar to how it was at the start. Metal system trace indicates roughly equal number of allocations and deallocations for buffers and textures (assume that the discrepancy comes from the actual Flutter rendering itself).
Android: SM-F731B, Android 14, using Impeller with Vulkan on Adreno 740
Running the same app through Android Studio and enabling the Live Telemetry in the Profiler shows the following after a minute or so:
The native allocations: (seems to point towards CommandBuffer and RenderPass usage)
From another run on the latest master:
Arranged by callstack, sorted by remaining size after a 1 minute run:
Code sample
Sample project is at: https://github.com/kekland/flutter_gpu_memory_leak
Screenshots or Video
No response
Logs
No response
Flutter Doctor output
Doctor output
kekland@Erzhans-MacBook-Pro flutter_gpu_memory_leak % fvm flutter doctor -v
[✓] Flutter (Channel master, 3.30.0-1.0.pre.189, on macOS 15.0.1 24A348 darwin-arm64, locale en-US) [5.8s]
• Flutter version 3.30.0-1.0.pre.189 on channel master at /Users/kekland/fvm/versions/master
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 87196771eb (12 days ago), 2025-02-14 16:02:09 -0800
• Engine revision 87196771eb
• Dart version 3.8.0 (build 3.8.0-91.0.dev)
• DevTools version 2.43.0
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0-rc4) [2.6s]
• Android SDK at /Users/kekland/Library/Android/sdk
• Platform android-35, build-tools 35.0.0-rc4
• ANDROID_HOME = /Users/kekland/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
• All Android licenses accepted.
[!] Xcode - develop for iOS and macOS (Xcode 16.0) [1,188ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16A242d
! CocoaPods 1.15.2 out of date (1.16.2 is recommended).
CocoaPods is a package manager for iOS or macOS platform code.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/to/platform-plugins
To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods
[✓] Chrome - develop for the web [13ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.2) [13ms]
• 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 21.0.5+-12932927-b750.29)
[✓] VS Code (version 1.97.2) [12ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.105.20250203
[✓] Connected device (4 available) [11.0s]
• SM F731B (mobile) • 192.168.0.20:44079 • android-arm64 • Android 14 (API 34)
• iPhone 16 (mobile) • 365FB7D3-6629-4B3C-B4D8-DF1A375E1509 • ios • com.apple.CoreSimulator.SimRuntime.iOS-18-0 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 15.0.1 24A348 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 133.0.6943.128
! Error: Browsing on the local area network for Hellomik. Ensure the device is unlocked and attached with a cable or associated with the same local area
network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
! Error: Browsing on the local area network for Erzhan’s iPhone 11 Pro. Ensure the device is unlocked and attached with a cable or associated with the same
local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources [444ms]
• All expected network resources are available.Metadata
Metadata
Assignees
Labels
Type
Projects
Status