This page describes how to configure memory usage tracking. See other information on memory debugging here.
Dart and Flutter applications can be configured to automatically trigger memory usage events and, in case of memory overuse, to save memory heap snapshots to hard drive. The snapshots can be later analyzed in DevTools.
Screen.Recording.2023-04-27.at.11.05.00.AM.mov
Use the function trackMemoryUsage
to configure usage events and auto-snapshotting.
See example.
We recommend to have auto-snapshotting off by default, with possibility to enable it via command line arguments in case of reported memory issues.
Use CLI to analyze the collected snapshots.
Upvote the issue to enable graphical snapshot analysis with DevTools.
Usage tracking does not work for web platform.
While usage tracking events are available for all modes, auto-snapshotting is on or off depending on the build mode:
- Enabled for: Flutter debug and profile modes (equivalent to Dart debug and release modes).
- Disabled for: Flutter release mode (equivalent to Dart product mode).
See Dart build modes or Flutter build modes.