-
-
Notifications
You must be signed in to change notification settings - Fork 893
Description
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