Memory usage tracking and auto-snapshotting

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.

https://user-images.githubusercontent.com/12115586/234953319-6f864d25-9854-4126-b4d6-8e114b9045ff.mov

Configure usage tracking

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.

Analyze snapshots

Use CLI to analyze the collected snapshots.

Upvote the issue to enable graphical snapshot analysis with DevTools.

Auto-snapshotting limitations

By platform

Usage tracking does not work for web platform.

By build mode

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.