Skip to content

[BUG] Excessive GPU Memory Usage: Old Tile Images Are Never Reclaimed, App Death Ensues #2006

Closed as not planned

Description

@corepuncher

What is the bug?

When using multiple TileLayers with frequently changing urlTemplate, my application’s GPU memory usage continues to increase over time. Even after older URLs are no longer referenced, or after certain TileLayers are no longer visually needed, flutter_map appears to retain those textures in GPU memory. For example, GL mtrack over 3.5 GB before device forcibly closes the app:

** MEMINFO in pid 3605 [com.myapp.myapp] **
                   Pss  Private  Private  SwapPss      Rss     Heap     Heap     Heap
                 Total    Dirty    Clean    Dirty    Total     Size    Alloc     Free
                ------   ------   ------   ------   ------   ------   ------   ------
  Native Heap   119067   109828     9228    81685   119308   213812   180648    33163
  Dalvik Heap     8933     3020     5836      863     9280    11225     5081     6144
 Dalvik Other    10674     8548      712      273    12168
        Stack     1252     1156       96     1536     1260
       Ashmem        0        0        0        0       36
      Gfx dev        0        0        0        0        4
    Other dev       14        0        8        0      432
     .so mmap     2772      120     1540      533    12316
    .jar mmap     2492        0     1608        0     7144
    .apk mmap    10811      556    10152       56    10916
    .ttf mmap      107        0       12        0      748
    .dex mmap        0        0        0        0       16
    .oat mmap       70        0       60        0      492
    .art mmap    10049      260     8956     6649    15296
   Other mmap   945887   944384     1076        0   946436
   EGL mtrack    57352    57352        0        0    57352
    GL mtrack  3502976  3502976        0        0  3502976
      Unknown   488650   486260     2388   204612   488724
        TOTAL  5457313  5114460    41672   296207  5184904   225037   185729    39307

How can we reproduce it?

Well, add something like 72 TileLayer(), and update each URL every 5 minutes. Pan the map around from time to time, and also run:

adb shell dumpsys meminfo com.myapp.myapp

...and watch the GPU memory grow forever.

It could be this is an issue "most" people do not bump up against, but is magnified given my situation.

Do you have a potential solution?

If it doesn't already exist, add a way to force tile disposal for old URLs and/or old keys. Possibly exposing a new “evict” API (similar to old tileStore concept).

Provide documentation clarifying how to remove stale GPU textures (e.g., remove the TileLayer from the widget tree entirely, wait for disposal, etc.)

Platforms

Galaxy S23

Severity

Fatal: Causes the application to crash

Activity

  1. added
    needs triage
    on Jan 2, 2025
  2. corepuncher commented on Jan 2, 2025

    @corepuncher
    Author

    I performed a sequential test. First, with Skia, and then Impeller.

    I loaded the app and panned around (or snapped programmatically to a lat/lon).

    After each step, I ran:

    adb shell dumpsys meminfo com.myapp.myapp

    TLDR:
    The root issue seems to be a lack of robust tile/texture eviction within flutter_map or the Flutter engine.
    Impeller only magnifies the memory growth issue (Flutter 3.27+ default on Android now).
    The test suggests that once a tile texture is uploaded to GPU memory, neither backend is discarding it—leading to near-monotonic growth.

    Below you will find the SKIA test with memory numbers (pay attention to GL mtrack and TOTAL), followed by Impeller test. Basically the same result, except even more GPU memory locked up. People would not see these values in devtools.

    
    Device:  Galaxy S23 Plus
    
    ====================
    ====== SKIA ========
    ====================
    NO IMPELLER: flutter run --debug --no-enable-impeller
    
    36 TileLayers (single image type, one for each timestamp)
    
    ====================
    ==> APP START:
    ====================
    
    ** MEMINFO in pid 29066 [com.myApp.myApp] **
                       Pss  Private  Private  SwapPss      Rss     Heap     Heap     Heap
                     Total    Dirty    Clean    Dirty    Total     Size    Alloc     Free
                    ------   ------   ------   ------   ------   ------   ------   ------
      Native Heap    58944    58912       12       32    59508    70520    57262    13256
      Dalvik Heap     3364     3292        0      102     4184    11241     5097     6144
     Dalvik Other    11756     3992        4        0    19840
            Stack     2076     2076        0        0     2084
           Ashmem       12        0        0        0      452
          Gfx dev        0        0        0        0        4
        Other dev       32        4       24        0      508
         .so mmap     4214      228     1460        4    30080
        .jar mmap     9704        0     6472        0    38684
        .apk mmap    37213      628    35316        0    43640
        .ttf mmap      388        0       64        0     2288
        .dex mmap       36        0        8        0      696
        .oat mmap      204        0      100        0     1304
        .art mmap    10230     8172     1208      103    22416
       Other mmap    96737    16424     3864        0   174040
       EGL mtrack    38440    38440        0        0    38440
        GL mtrack   390516   390516        0        0   390516
          Unknown   639781   639572      168        2   640236
            TOTAL  1303890  1162256    48700      243  1468920    81761    62359    19400
    
     App Summary
                           Pss(KB)                        Rss(KB)
                            ------                         ------
               Java Heap:    12672                          26600
             Native Heap:    58912                          59508
                    Code:    44556                         132500
                   Stack:     2076                           2084
                Graphics:   428956                         428960
           Private Other:   663784
                  System:    92934
                 Unknown:                                  819268
    
               TOTAL PSS:  1303890            TOTAL RSS:  1468920       TOTAL SWAP PSS:      243
    
     Objects
                   Views:        8         ViewRootImpl:        1
             AppContexts:       14           Activities:        1
                  Assets:       34        AssetManagers:        0
           Local Binders:       42        Proxy Binders:       57
           Parcel memory:       17         Parcel count:       65
        Death Recipients:        3             WebViews:        0
    
     SQL
             MEMORY_USED:      110
      PAGECACHE_OVERFLOW:       44          MALLOC_SIZE:       46
    
     DATABASES
          pgsz     dbsz   Lookaside(b) cache hits cache misses cache size  Dbname
    PER CONNECTION STATS
             4       56             70    33    35     6  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    POOL STATS
         cache hits  cache misses    cache size  Dbname
                 33            36            69  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    
     Asset Allocations
        : 1607K
        : 1277K
    
    
    ====================
    ==> ADD 2nd Image Layer (72 total TileLayers):
    ====================
    
    ** MEMINFO in pid 29066 [com.myApp.myApp] **
                       Pss  Private  Private  SwapPss      Rss     Heap     Heap     Heap
                     Total    Dirty    Clean    Dirty    Total     Size    Alloc     Free
                    ------   ------   ------   ------   ------   ------   ------   ------
      Native Heap    81557    81524       12       32    82120    91840    65467    26372
      Dalvik Heap     5875     3336       56       30     9384    11233     5089     6144
     Dalvik Other    11772     3832        4        0    20044
            Stack     1944     1944        0        0     1952
           Ashmem       13        0        0        0      452
          Gfx dev        0        0        0        0        4
        Other dev       32        4       24        0      508
         .so mmap     4461      228     1764        4    30084
        .jar mmap    10453        0     7280        0    38996
        .apk mmap    37521      628    35776        0    43704
        .ttf mmap      388        0       64        0     2288
        .dex mmap       39        0       12        0      696
        .oat mmap      268        0      204        0     1304
        .art mmap    11182     8188     1232       76    24456
       Other mmap    99655    19332     3848        0   176980
       EGL mtrack    38440    38440        0        0    38440
        GL mtrack   884932   884932        0        0   884932
          Unknown   655002   654792      168        2   655456
            TOTAL  1843678  1697180    50444      144  2011800   103073    70556    32516
    
     App Summary
                           Pss(KB)                        Rss(KB)
                            ------                         ------
               Java Heap:    12756                          33840
             Native Heap:    81524                          82120
                    Code:    46240                         133188
                   Stack:     1944                           1952
                Graphics:   923372                         923376
           Private Other:   681788
                  System:    96054
                 Unknown:                                  837324
    
               TOTAL PSS:  1843678            TOTAL RSS:  2011800       TOTAL SWAP PSS:      144
    
     Objects
                   Views:        8         ViewRootImpl:        1
             AppContexts:       14           Activities:        1
                  Assets:       34        AssetManagers:        0
           Local Binders:       30        Proxy Binders:       53
           Parcel memory:       15         Parcel count:       59
        Death Recipients:        3             WebViews:        0
    
     SQL
             MEMORY_USED:      110
      PAGECACHE_OVERFLOW:       44          MALLOC_SIZE:       46
    
     DATABASES
          pgsz     dbsz   Lookaside(b) cache hits cache misses cache size  Dbname
    PER CONNECTION STATS
             4       56             70    33    38     6  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    POOL STATS
         cache hits  cache misses    cache size  Dbname
                 33            39            72  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    
     Asset Allocations
        : 1607K
        : 1277K
    
    
    ====================
    ==> Snap map to Boston:
    ====================
    
    ** MEMINFO in pid 29066 [com.myApp.myApp] **
                       Pss  Private  Private  SwapPss      Rss     Heap     Heap     Heap
                     Total    Dirty    Clean    Dirty    Total     Size    Alloc     Free
                    ------   ------   ------   ------   ------   ------   ------   ------
      Native Heap    94072    94044        4       30    94664   101368    72624    28743
      Dalvik Heap     5963     3444       52       28     9476    11377     5233     6144
     Dalvik Other    14116     4056        4        0    24480
            Stack     1880     1880        0        0     1888
           Ashmem       11        0        0        0      452
          Gfx dev        0        0        0        0        4
        Other dev       29        4       24        0      528
         .so mmap     3440      232      424        2    31052
        .jar mmap     7751        0     3744        0    40300
        .apk mmap    36745      628    34964        0    43324
        .ttf mmap      479        0      136        0     3208
        .dex mmap       24        0        0        0      696
        .oat mmap       92        0        4        0     1344
        .art mmap    11275     8364     1180       68    24692
       Other mmap    93932    14144     3456        0   171124
       EGL mtrack    58584    58584        0        0    58584
        GL mtrack   951128   951128        0        0   951128
          Unknown   685986   685852       72        2   686488
            TOTAL  1965637  1822360    44064      130  2143432   112745    77857    34887
    
     App Summary
                           Pss(KB)                        Rss(KB)
                            ------                         ------
               Java Heap:    12988                          34168
             Native Heap:    94044                          94664
                    Code:    40468                         140332
                   Stack:     1880                           1888
                Graphics:  1009712                        1009716
           Private Other:   707332
                  System:    99213
                 Unknown:                                  862664
    
               TOTAL PSS:  1965637            TOTAL RSS:  2143432       TOTAL SWAP PSS:      130
    
     Objects
                   Views:        8         ViewRootImpl:        1
             AppContexts:       14           Activities:        1
                  Assets:       34        AssetManagers:        0
           Local Binders:       42        Proxy Binders:       55
           Parcel memory:       16         Parcel count:       61
        Death Recipients:        3             WebViews:        0
    
     SQL
             MEMORY_USED:      164
      PAGECACHE_OVERFLOW:       74          MALLOC_SIZE:       46
    
     DATABASES
          pgsz     dbsz   Lookaside(b) cache hits cache misses cache size  Dbname
    PER CONNECTION STATS
             4       56            122    56    75    17  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    POOL STATS
         cache hits  cache misses    cache size  Dbname
                 56            76           132  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    
     Asset Allocations
        : 1607K
        : 1277K
    
    ====================
    ==> Snap map to Seattle:
    ====================
    
    ** MEMINFO in pid 29066 [com.myApp.myApp] **
                       Pss  Private  Private  SwapPss      Rss     Heap     Heap     Heap
                     Total    Dirty    Clean    Dirty    Total     Size    Alloc     Free
                    ------   ------   ------   ------   ------   ------   ------   ------
      Native Heap   121160   121132        4       30   121752   126360    80347    46012
      Dalvik Heap     7523     5004       52       28    11036    11397     5253     6144
     Dalvik Other    14084     3980        4        0    24492
            Stack     1904     1904        0        0     1912
           Ashmem       11        0        0        0      452
          Gfx dev        0        0        0        0        4
        Other dev       29        4       24        0      528
         .so mmap     3438      232      424        2    31052
        .jar mmap     7718        0     3684        0    40300
        .apk mmap    38113      628    36332        0    44692
        .ttf mmap      479        0      136        0     3208
        .dex mmap       24        0        0        0      696
        .oat mmap       92        0        4        0     1344
        .art mmap    11271     8364     1180       68    24692
       Other mmap    93624    13836     3456        0   170816
       EGL mtrack    68040    68040        0        0    68040
        GL mtrack  1436560  1436560        0        0  1436560
          Unknown   720298   720184       52        2   720800
            TOTAL  2524498  2379868    45352      130  2702376   137757    85600    52156
    
     App Summary
                           Pss(KB)                        Rss(KB)
                            ------                         ------
               Java Heap:    14548                          35728
             Native Heap:   121132                         121752
                    Code:    41768                         141780
                   Stack:     1904                           1912
                Graphics:  1504600                        1504604
           Private Other:   741268
                  System:    99278
                 Unknown:                                  896600
    
               TOTAL PSS:  2524498            TOTAL RSS:  2702376       TOTAL SWAP PSS:      130
    
     Objects
                   Views:        8         ViewRootImpl:        1
             AppContexts:       14           Activities:        1
                  Assets:       35        AssetManagers:        0
           Local Binders:       49        Proxy Binders:       73
           Parcel memory:       16         Parcel count:       61
        Death Recipients:        3             WebViews:        0
    
     SQL
             MEMORY_USED:      164
      PAGECACHE_OVERFLOW:       74          MALLOC_SIZE:       46
    
     DATABASES
          pgsz     dbsz   Lookaside(b) cache hits cache misses cache size  Dbname
    PER CONNECTION STATS
             4       56            122    56    78    17  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    POOL STATS
         cache hits  cache misses    cache size  Dbname
                 56            79           135  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    
     Asset Allocations
        : 1607K
        : 1277K
    
    ====================
    ==> 4-5 short map flings to North Dakota:
    ====================
    
    ** MEMINFO in pid 8548 [com.myApp.myApp] **
                       Pss  Private  Private  SwapPss      Rss     Heap     Heap     Heap
                     Total    Dirty    Clean    Dirty    Total     Size    Alloc     Free
                    ------   ------   ------   ------   ------   ------   ------   ------
      Native Heap   110138   110088       32       36   110692   114088    84707    29380
      Dalvik Heap     5519     3684      132       30     9732    11265     5121     6144
     Dalvik Other    12897     4068        4        0    22064
            Stack     1832     1832        0        0     1840
           Ashmem       42        0        0        0      336
          Gfx dev        0        0        0        0        4
        Other dev       61       24       24        0      524
         .so mmap     5396      224     2848        4    28628
        .jar mmap     7775        0     3248        0    35740
        .apk mmap    38028      628    35816        0    42308
        .ttf mmap      628        0      328        0     3244
        .dex mmap       84        0       28        0      712
        .oat mmap      164        0       40        0     1132
        .art mmap    11130     8064     1796      256    24232
       Other mmap    92807    14240     3576        0   168548
       EGL mtrack    78112    78112        0        0    78112
        GL mtrack  1581764  1581764        0        0  1581764
          Unknown   712264   712004      208       30   712656
            TOTAL  2658997  2514732    48080      356  2822268   125353    89828    35524
    
     App Summary
                           Pss(KB)                        Rss(KB)
                            ------                         ------
               Java Heap:    13544                          33964
             Native Heap:   110088                         110692
                    Code:    43516                         129736
                   Stack:     1832                           1840
                Graphics:  1659876                        1659880
           Private Other:   733956
                  System:    96185
                 Unknown:                                  886156
    
               TOTAL PSS:  2658997            TOTAL RSS:  2822268       TOTAL SWAP PSS:      356
    
     Objects
                   Views:        8         ViewRootImpl:        1
             AppContexts:       14           Activities:        1
                  Assets:       34        AssetManagers:        0
           Local Binders:       80        Proxy Binders:       54
           Parcel memory:       17         Parcel count:       67
        Death Recipients:        3             WebViews:        0
    
     SQL
             MEMORY_USED:      110
      PAGECACHE_OVERFLOW:       44          MALLOC_SIZE:       46
    
     DATABASES
          pgsz     dbsz   Lookaside(b) cache hits cache misses cache size  Dbname
    PER CONNECTION STATS
             4       56             70    33    47     6  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    POOL STATS
         cache hits  cache misses    cache size  Dbname
                 33            48            81  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    
     Asset Allocations
        : 1607K
        : 1277K
    
    ====================
    ==> Snap map back to starting point:
    ====================
    
    ** MEMINFO in pid 8548 [com.myApp.myApp] **
                       Pss  Private  Private  SwapPss      Rss     Heap     Heap     Heap
                     Total    Dirty    Clean    Dirty    Total     Size    Alloc     Free
                    ------   ------   ------   ------   ------   ------   ------   ------
      Native Heap   129102   129052       32       36   129656   133640    96271    37368
      Dalvik Heap     5303     3468      132       30     9516    11269     5125     6144
     Dalvik Other    12897     4068        4        0    22064
            Stack     1832     1832        0        0     1840
           Ashmem       39        0        0        0      300
          Gfx dev        0        0        0        0        4
        Other dev       53       24       16        0      516
         .so mmap     5396      224     2848        4    28624
        .jar mmap     7775        0     3248        0    35740
        .apk mmap    38650      628    36976        0    42308
        .ttf mmap      628        0      328        0     3244
        .dex mmap       84        0       28        0      712
        .oat mmap      164        0       40        0     1132
        .art mmap    11097     8060     1768      261    24188
       Other mmap    97587    19020     3576        0   173328
       EGL mtrack    78112    78112        0        0    78112
        GL mtrack  2257328  2257328        0        0  2257328
          Unknown   721456   721196      208       46   721844
            TOTAL  3367880  3223012    49204      377  3530456   144909   101396    43512
    
     App Summary
                           Pss(KB)                        Rss(KB)
                            ------                         ------
               Java Heap:    13296                          33704
             Native Heap:   129052                         129656
                    Code:    44676                         129732
                   Stack:     1832                           1840
                Graphics:  2335440                        2335444
           Private Other:   747920
                  System:    95664
                 Unknown:                                  900080
    
               TOTAL PSS:  3367880            TOTAL RSS:  3530456       TOTAL SWAP PSS:      377
    
     Objects
                   Views:        8         ViewRootImpl:        1
             AppContexts:       14           Activities:        1
                  Assets:       34        AssetManagers:        0
           Local Binders:       83        Proxy Binders:       54
           Parcel memory:       17         Parcel count:       67
        Death Recipients:        3             WebViews:        0
    
     SQL
             MEMORY_USED:      110
      PAGECACHE_OVERFLOW:       44          MALLOC_SIZE:       46
    
     DATABASES
          pgsz     dbsz   Lookaside(b) cache hits cache misses cache size  Dbname
    PER CONNECTION STATS
             4       56             70    33    50     6  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    POOL STATS
         cache hits  cache misses    cache size  Dbname
                 33            51            84  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    
     Asset Allocations
        : 1607K
        : 1277K
        
        
        
    ====================
    ===== IMPELLER =====
    ====================
    USING IMPELLER: flutter run --debug
    
    36 TileLayers (single image type, one for each timestamp):
    
    ====================
    ==> APP START:
    ====================
    
    ** MEMINFO in pid 29786 [com.myApp.myApp] **
                       Pss  Private  Private  SwapPss      Rss     Heap     Heap     Heap
                     Total    Dirty    Clean    Dirty    Total     Size    Alloc     Free
                    ------   ------   ------   ------   ------   ------   ------   ------
      Native Heap    87477    87452        4       32    88044   114284   103351    10932
      Dalvik Heap     3354     3288        0      104     4180    11237     5093     6144
     Dalvik Other    11748     4008        4        0    19808
            Stack     2868     2868        0        0     2876
           Ashmem       12        0        0        0      452
          Gfx dev        0        0        0        0        4
        Other dev      383      344       24        0     1008
         .so mmap    15388      644    11652        4    43632
        .jar mmap     7306        0     3244        0    40016
        .apk mmap    37008      628    35340        0    43192
        .ttf mmap      349        0       76        0     2244
        .dex mmap       24        0        0        0      696
        .oat mmap       91        0        0        0     1344
        .art mmap    10182     8168     1176      104    22408
       Other mmap   113966    34472     3636        0   190700
       EGL mtrack    57352    57352        0        0    57352
        GL mtrack   910712   910712        0        0   910712
          Unknown   633809   633652       96        2   634288
            TOTAL  1892275  1743588    55252      246  2062956   125521   108444    17076
    
     App Summary
                           Pss(KB)                        Rss(KB)
                            ------                         ------
               Java Heap:    12632                          26588
             Native Heap:    87452                          88044
                    Code:    51884                         146904
                   Stack:     2868                           2876
                Graphics:   968064                         968068
           Private Other:   675940
                  System:    93435
                 Unknown:                                  830476
    
               TOTAL PSS:  1892275            TOTAL RSS:  2062956       TOTAL SWAP PSS:      246
    
     Objects
                   Views:        8         ViewRootImpl:        1
             AppContexts:       14           Activities:        1
                  Assets:       34        AssetManagers:        0
           Local Binders:       45        Proxy Binders:       57
           Parcel memory:       17         Parcel count:       65
        Death Recipients:        3             WebViews:        0
    
     SQL
             MEMORY_USED:      110
      PAGECACHE_OVERFLOW:       44          MALLOC_SIZE:       46
    
     DATABASES
          pgsz     dbsz   Lookaside(b) cache hits cache misses cache size  Dbname
    PER CONNECTION STATS
             4       56             70    33    35     6  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    POOL STATS
         cache hits  cache misses    cache size  Dbname
                 33            36            69  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    
     Asset Allocations
        : 1607K
        : 1277K
    
    ====================
    ==> ADD 2nd Image Layer (72 total TileLayers):
    ====================
    
    ** MEMINFO in pid 29786 [com.myApp.myApp] **
                       Pss  Private  Private  SwapPss      Rss     Heap     Heap     Heap
                     Total    Dirty    Clean    Dirty    Total     Size    Alloc     Free
                    ------   ------   ------   ------   ------   ------   ------   ------
      Native Heap   103245   103220        4       32   103812   123544   108828    14715
      Dalvik Heap     5870     3352       52       30     9400    11237     5093     6144
     Dalvik Other    11918     3992       32        0    20148
            Stack     2452     2452        0        0     2460
           Ashmem       12        0        0        0      452
          Gfx dev        0        0        0        0        4
        Other dev      382      344       24        0     1008
         .so mmap    15337      644    11616        4    43632
        .jar mmap     7451        0     3504        0    40288
        .apk mmap    37048      628    35384        0    43260
        .ttf mmap      349        0       76        0     2244
        .dex mmap       22        0        0        0      696
        .oat mmap       84        0        0        0     1344
        .art mmap    11104     8184     1192       76    24452
       Other mmap   152000    72524     3628        0   228752
       EGL mtrack    57352    57352        0        0    57352
        GL mtrack  1236008  1236008        0        0  1236008
          Unknown   632100   631944       96        2   632580
            TOTAL  2272878  2120644    55608      144  2447892   134781   113921    20859
    
     App Summary
                           Pss(KB)                        Rss(KB)
                            ------                         ------
               Java Heap:    12728                          33852
             Native Heap:   103220                         103812
                    Code:    52140                         147528
                   Stack:     2452                           2460
                Graphics:  1293360                        1293364
           Private Other:   712352
                  System:    96626
                 Unknown:                                  866876
    
               TOTAL PSS:  2272878            TOTAL RSS:  2447892       TOTAL SWAP PSS:      144
    
     Objects
                   Views:        8         ViewRootImpl:        1
             AppContexts:       14           Activities:        1
                  Assets:       35        AssetManagers:        0
           Local Binders:       45        Proxy Binders:       53
           Parcel memory:       15         Parcel count:       59
        Death Recipients:        3             WebViews:        0
    
     SQL
             MEMORY_USED:      110
      PAGECACHE_OVERFLOW:       44          MALLOC_SIZE:       46
    
     DATABASES
          pgsz     dbsz   Lookaside(b) cache hits cache misses cache size  Dbname
    PER CONNECTION STATS
             4       56             70    33    38     6  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    POOL STATS
         cache hits  cache misses    cache size  Dbname
                 33            39            72  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    
     Asset Allocations
        : 1607K
        : 1277K
        : 17K
    
    ====================
    ==> Snap map to Boston: 
    ====================
    
    ** MEMINFO in pid 29786 [com.myApp.myApp] **
                       Pss  Private  Private  SwapPss      Rss     Heap     Heap     Heap
                     Total    Dirty    Clean    Dirty    Total     Size    Alloc     Free
                    ------   ------   ------   ------   ------   ------   ------   ------
      Native Heap   172674   172648        4       32   173252   189088   124695    64392
      Dalvik Heap     7384     4864       52       30    10912    11273     5129     6144
     Dalvik Other    12901     4104       32        0    22004
            Stack     2492     2492        0        0     2500
           Ashmem       12        0        0        0      452
          Gfx dev        0        0        0        0        4
        Other dev      382      344       24        0     1008
         .so mmap    14981      644    11452        4    42764
        .jar mmap     5835        0     2380        0    37204
        .apk mmap    38165      628    36660        0    44088
        .ttf mmap      446        0      112        0     3172
        .dex mmap       22        0        0        0      696
        .oat mmap       66        0        0        0     1256
        .art mmap     8177     5236     1200     3079    21556
       Other mmap   308801   230408     3204        0   384872
       EGL mtrack    87568    87568        0        0    87568
        GL mtrack  2199036  2199036        0        0  2199036
          Unknown   662060   661968       32        2   662540
            TOTAL  3524149  3369940    55152     3147  3694884   200361   129824    70536
    
     App Summary
                           Pss(KB)                        Rss(KB)
                            ------                         ------
               Java Heap:    11300                          32468
             Native Heap:   172648                         173252
                    Code:    52244                         147068
                   Stack:     2492                           2500
                Graphics:  2286604                        2286608
           Private Other:   899804
                  System:    99057
                 Unknown:                                 1052988
    
               TOTAL PSS:  3524149            TOTAL RSS:  3694884       TOTAL SWAP PSS:     3147
    
     Objects
                   Views:        8         ViewRootImpl:        1
             AppContexts:       14           Activities:        1
                  Assets:       36        AssetManagers:        0
           Local Binders:       40        Proxy Binders:       72
           Parcel memory:       16         Parcel count:       63
        Death Recipients:        3             WebViews:        0
    
     SQL
             MEMORY_USED:      110
      PAGECACHE_OVERFLOW:       44          MALLOC_SIZE:       46
    
     DATABASES
          pgsz     dbsz   Lookaside(b) cache hits cache misses cache size  Dbname
    PER CONNECTION STATS
             4       56             70    33    41     6  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    POOL STATS
         cache hits  cache misses    cache size  Dbname
                 33            42            75  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    
     Asset Allocations
        : 1607K
        : 1277K
        : 17K
    
    ====================
    ==> Snap map to Seattle:
    ====================
    
    ** MEMINFO in pid 29786 [com.myApp.myApp] **
                       Pss  Private  Private  SwapPss      Rss     Heap     Heap     Heap
                     Total    Dirty    Clean    Dirty    Total     Size    Alloc     Free
                    ------   ------   ------   ------   ------   ------   ------   ------
      Native Heap   172610   172584        4       44   173188   184556   133144    51411
      Dalvik Heap     5726     3204       52      162     9252    11261     5117     6144
     Dalvik Other    12909     4080       32        0    22044
            Stack     2480     2480        0        0     2488
           Ashmem       11        0        0        0      416
          Gfx dev        0        0        0        0        4
        Other dev      381      344       24        0      996
         .so mmap    14783      700    11244        4    42368
        .jar mmap     5736        0     2312        0    36856
        .apk mmap    35713      628    34196        0    41300
        .ttf mmap      431        0      100        0     3148
        .dex mmap       22        0        0        0      696
        .oat mmap       66        0        0        0     1256
        .art mmap     7199     2976     2484     4059    20576
       Other mmap   410876   333064     3128        0   486424
       EGL mtrack    87568    87568        0        0    87568
        GL mtrack  2335364  2335364        0        0  2335364
          Unknown   628352   628164      128    71846   628832
            TOTAL  3796342  3571156    53704    76115  3892776   195817   138261    57555
    
     App Summary
                           Pss(KB)                        Rss(KB)
                            ------                         ------
               Java Heap:     8664                          29828
             Native Heap:   172584                         173188
                    Code:    49552                         143580
                   Stack:     2480                           2488
                Graphics:  2422932                        2422936
           Private Other:   968648
                  System:   171482
                 Unknown:                                 1120756
    
               TOTAL PSS:  3796342            TOTAL RSS:  3892776       TOTAL SWAP PSS:    76115
    
     Objects
                   Views:        8         ViewRootImpl:        1
             AppContexts:       14           Activities:        1
                  Assets:       35        AssetManagers:        0
           Local Binders:       38        Proxy Binders:       54
           Parcel memory:       17         Parcel count:       65
        Death Recipients:        3             WebViews:        0
    
     SQL
             MEMORY_USED:      110
      PAGECACHE_OVERFLOW:       44          MALLOC_SIZE:       46
    
     DATABASES
          pgsz     dbsz   Lookaside(b) cache hits cache misses cache size  Dbname
    PER CONNECTION STATS
             4       56             70    33    56     6  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    POOL STATS
         cache hits  cache misses    cache size  Dbname
                 33            57            90  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    
     Asset Allocations
        : 1607K
        : 1277K
        : 17K
    
    ====================
    ==> 4-5 short map flings to North Dakota:
    ====================
    
    ** MEMINFO in pid 29786 [com.myApp.myApp] **
                       Pss  Private  Private  SwapPss      Rss     Heap     Heap     Heap
                     Total    Dirty    Clean    Dirty    Total     Size    Alloc     Free
                    ------   ------   ------   ------   ------   ------   ------   ------
      Native Heap   172237   172156       64     6856   172784   195164   129154    66009
      Dalvik Heap     4749     3104        4      222     8908    11261     5117     6144
     Dalvik Other    11753     3600        0      168    20248
            Stack     1852     1848        4      592     1860
           Ashmem        4        0        0        0      156
          Gfx dev        0        0        0        0        4
        Other dev      110       96        8        0      652
         .so mmap    13321      412    10740      236    38024
        .jar mmap     2379        0      476        0    27252
        .apk mmap    35000      628    33744        0    39628
        .ttf mmap      422        0      108        0     3080
        .dex mmap       16        0        0        0      672
        .oat mmap       28        0        0        0      872
        .art mmap     3150     1620      524     6461    15320
       Other mmap   475548   437236     1668        0   512904
       EGL mtrack    87568    87568        0        0    87568
        GL mtrack  2822608  2822608        0        0  2822608
          Unknown   589239   589040      180   101052   589440
            TOTAL  4335571  4119916    47520   115587  4341980   206425   134271    72153
    
     App Summary
                           Pss(KB)                        Rss(KB)
                            ------                         ------
               Java Heap:     5248                          24228
             Native Heap:   172156                         172784
                    Code:    46164                         125856
                   Stack:     1848                           1860
                Graphics:  2910176                        2910180
           Private Other:  1031844
                  System:   168135
                 Unknown:                                 1107072
    
               TOTAL PSS:  4335571            TOTAL RSS:  4341980       TOTAL SWAP PSS:   115587
    
     Objects
                   Views:        8         ViewRootImpl:        1
             AppContexts:       14           Activities:        1
                  Assets:       35        AssetManagers:        0
           Local Binders:       68        Proxy Binders:       54
           Parcel memory:       17         Parcel count:       65
        Death Recipients:        3             WebViews:        0
    
     SQL
             MEMORY_USED:      110
      PAGECACHE_OVERFLOW:       44          MALLOC_SIZE:       46
    
     DATABASES
          pgsz     dbsz   Lookaside(b) cache hits cache misses cache size  Dbname
    PER CONNECTION STATS
             4       56             70    33    59     6  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    POOL STATS
         cache hits  cache misses    cache size  Dbname
                 33            60            93  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    
     Asset Allocations
        : 1607K
        : 1277K
        : 17K
    
    ====================
    ==> Snap map back to starting point:
    ====================
    
    ** MEMINFO in pid 29786 [com.myApp.myApp] **
                       Pss  Private  Private  SwapPss      Rss     Heap     Heap     Heap
                     Total    Dirty    Clean    Dirty    Total     Size    Alloc     Free
                    ------   ------   ------   ------   ------   ------   ------   ------
      Native Heap   296493   296400       76     6748   297036   344948   290822    54125
      Dalvik Heap     5137     3212      280      166     9292    11261     5117     6144
     Dalvik Other    11705     3600        0      168    20152
            Stack     2036     2032        4      592     2044
           Ashmem        4        0        0        0      156
          Gfx dev        0        0        0        0        4
        Other dev       87       76        8        0      600
         .so mmap    10211      412     8104      236    32508
        .jar mmap     1316        0      212        0    21376
        .apk mmap    31903      628    30820        0    35484
        .ttf mmap      403        0      100        0     3028
        .dex mmap       10        0        0        0      532
        .oat mmap       11        0        0        0      688
        .art mmap     4186     1600     1288     6353    16648
       Other mmap   497115   470188     1396        0   523284
       EGL mtrack    87568    87568        0        0    87568
        GL mtrack  2858752  2858752        0        0  2858752
          Unknown   608388   608240      132   100864   608580
            TOTAL  4530452  4332708    42420   115127  4517732   356209   295939    60269
    
     App Summary
                           Pss(KB)                        Rss(KB)
                            ------                         ------
               Java Heap:     6100                          25940
             Native Heap:   296400                         297036
                    Code:    40332                         109848
                   Stack:     2032                           2044
                Graphics:  2946320                        2946324
           Private Other:  1083944
                  System:   155324
                 Unknown:                                 1136540
    
               TOTAL PSS:  4530452            TOTAL RSS:  4517732       TOTAL SWAP PSS:   115127
    
     Objects
                   Views:        8         ViewRootImpl:        1
             AppContexts:       14           Activities:        1
                  Assets:       35        AssetManagers:        0
           Local Binders:       71        Proxy Binders:       54
           Parcel memory:       17         Parcel count:       65
        Death Recipients:        3             WebViews:        0
    
     SQL
             MEMORY_USED:      110
      PAGECACHE_OVERFLOW:       44          MALLOC_SIZE:       46
    
     DATABASES
          pgsz     dbsz   Lookaside(b) cache hits cache misses cache size  Dbname
    PER CONNECTION STATS
             4       56             70    33    65     6  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    POOL STATS
         cache hits  cache misses    cache size  Dbname
                 33            66            99  /data/user/0/com.myApp.myApp/databases/com.google.android.datatransport.events
    
     Asset Allocations
        : 1607K
        : 1277K
        : 17K
    
  3. JaffaKetchup commented on Jan 2, 2025

    @JaffaKetchup
    Member

    I haven't read through the logs in detail yet, but I suspect the first place to start would be to make sure the ImageCache is being used correctly.
    I seem to remember you said you've changed it? Is that in this app?

  4. corepuncher commented on Jan 2, 2025

    @corepuncher
    Author

    I haven't read through the logs in detail yet, but I suspect the first place to start would be to make sure the ImageCache is being used correctly. I seem to remember you said you've changed it? Is that in this app?

    Regarding the global image cache, the only things I do are:

    • set cache.maximumSize
    • set cache.maximumSizeBytes
    • Periodically clear imageCache.clear();

    But to rule out anything funny, I"ll comment all those out and test again now.

    As far as flutter map code I do not recall ever changing anything related to image caching.

    Also I posted a generalized app crash issue here (since it has to do with Impeller upgrade): flutter/flutter#160941

    Technically, the app STILL does crash, but not nearly as often using Skia.

  5. corepuncher commented on Jan 2, 2025

    @corepuncher
    Author

    Some more testing (went back and forth twice) on Android:

    SKIA: The GL mtrack memory periodically goes down during map panning/zooming, and the TOTAL memory seemed to stabilize. Typically around 2 GB GL mtrack and around 3GB TOTAL. And it's more common for these values to drop by a few hundred MB from time to time.

    IMPELLER:
    No matter what I do, the GL mtrack and TOTAL memory ONLY go up. Nothing ever seems to get removed from the GPU and eventually, the app is killed at around 3.5 GB GL mtrack and 5.3 GB TOTAL used.

    Those two examples above are same app, same imagery, same general usage/map behavior. Worlds apart.

    UPDATE: Also toyed with NOT setting imageCache max size, vs just using the default, and, just letting system clear it when needed. Not really much difference either way.

  6. corepuncher commented on Jan 5, 2025

    @corepuncher
    Author

    Well, it appears that flutter 3.27 (even when building "presumably" with impeller disabled) appears to use more memory, resulting in crashes. Either that, or something else has changed. Perhaps it is less aggressive in reclaiming memory or clearing image cache, IDK. So for now, I have reverted back to 3.24.5 :-(

    However, I have been working on mitigating crashes. I did two primary things:

    1. I use the debounce transformer on all TileLayer NOT currently visible (i.e., "beneath" the visible frame). That way giant slews of tiles are not pulled until panning or zooming ends.

    2. As a last resort, the app user can now flip a switch which will enable a special mode.
      Lets say we have a 36 frame loop. Before, I had all 36 frames loaded at once, and turn opacity on/off.
      Now, I only load half. This results in much less tile downloads (half) as the user pans or zooms.

    Now, for looping, this means we are only loading 18 out of 36 frames, (1 back in case user hits back button, and 17 "ahead").
    As the frames animate, the next 17 are of course downloaded. As each frame iterates, another TileLayer is created well ahead, while the one 2 frames ago is destroyed. Given these long loops, that is enough time to get new tiles downloaded if needed, but most of the time it appears that even though the tile layer is disposed, the image remains in the image cache (since I increased to 1GB).

    At first I was afraid that disposing the tile layer would result in new downloads, but thankfully that is NOT the case. So yay.

  7. mootw commented on Jan 6, 2025

    @mootw
    Contributor

    I would highly recommend not loading all layers at once, and instead, changing the tile URL for a single layer and let it handle swapping out tiles. This will avoid the memory issues you are experiencing. Though, i would recommend staying on 3.24.5 for the time being, given how unstable 3.27 has been so far

  8. JaffaKetchup commented on Feb 16, 2025

    @JaffaKetchup
    Member

    I'm going to have to mark this as external/won't fix, sorry! I'm not 100% sure we're causing the issue, as it seems to be so related to Impeller, and you are placing an unusually high strain on the Flutter image cache memory, so this issue is unlikely to appear for other users.

    However, I'm still interested in finding out more if you make any more discoveries, so feel free to comment here :)

  9. added and removed
    needs triage
    on Feb 16, 2025
  10. corepuncher commented on Feb 23, 2025

    @corepuncher
    Author

    I'm going to have to mark this as external/won't fix, sorry! I'm not 100% sure we're causing the issue, as it seems to be so related to Impeller, and you are placing an unusually high strain on the Flutter image cache memory, so this issue is unlikely to appear for other users.

    However, I'm still interested in finding out more if you make any more discoveries, so feel free to comment here :)

    No problem! Just want ya'll to be aware. I'll pass on any info I find. But be aware it may crop up for others over time as FM gets (even) more popular.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions