Understand the Garbage collector logs flutter

Here is the output of my logging of my flutter app :

Explicit concurrent copying GC freed 25188(844KB) AllocSpace objects, 1(20KB) LOS objects, 2% free, 301MB/309MB, paused 348us total 317.699ms

I would like to understand :

  • What does “LOS” mean ?
  • What is the “2% free” ? (The space that the garbage collector managed to free ? or the remaining RAM available ?)
  • What represents the 301MB and the 309MB ?

As i am using the flutter DevTools to look for memory, i am seeing very different numbers :

here

I have added the “Android” tag because i am running the app on Android 10 and i believe the answer would be the same for IOS.

Thanks in advance

Answer

This log messages are not coming from Flutter but Android itself. Based on the log format in your example I guess it is logging from ART (Android RunTime) and where the log format is described in details here the documentation: https://developer.android.com/studio/debug/am-logcat?hl=lt#ARTLogMessages

So to answer your questions:

What does “LOS” mean ?

Large Object Space

What is the “2% free” ? (The space that the garbage collector managed to free ? or the remaining RAM available ?). What represents the 301MB and the 309MB ?

From the linked documentation:

Heap stats

Percentage free and (number of live objects)/(total heap size).

So your current heap takes 309 MB memory, contains objects which takes 301 MB inside it. Which means 2% of the heap is free to be used.