-
-
Notifications
You must be signed in to change notification settings - Fork 348
Description
Mapsui Version
- Mapsui.Maui: 5.0.2
- Mapsui: 5.0.2
Platform(s)
- WinUI (MAUI)
- Android (MAUI)
- iOS (MAUI)
Describe the bug
After navigating to a page containing Mapsui.Maui.MapControl and then leaving the page,
the page and its visual tree are correctly garbage collected, but MapControl itself and
the underlying SKGLView are not collected.
This results in a memory leak that accumulates when navigating multiple times to/from a page
containing a MapControl.
The issue is reproducible on WinUI, Android and iOS.
Steps to reproduce
- Clone the repro project:
https://github.com/MereDoku/Mapsui.Maui.MemoryLeak.Repro - Build and run the app (WinUI / Android / iOS)
- From the first page, click "Open Map Page"
- Navigate back
- Trigger
VisualLeakCheckQueue.Monitor()(already wired in the repro) - Observe that
MapControlandSKGLVieware not garbage collected
Expected behavior
After leaving the page and running GC, MapControl and SKGLView should be garbage collected.
Actual behavior
MapControl and its underlying SKGLView remain alive after page navigation, causing
a memory leak.
Leak detector output
WinUI
MapPage => ✅ Collected
Grid => ✅ Collected
MapControl => 💦 Leak
SKGLView => 💦 Leak
Android
[0:] MapPage => ✅ Collected
[0:] - Grid => ✅ Collected
[0:] - MapControl => 💦 Leak
[0:] - SKGLView => 💦 Leak
iOS
[0:] MapPage => ✅ Collected
[0:] - Grid => ✅ Collected
[0:] - MapControl => 💦 Leak
[0:] - SKGLView => 💦 Leak
Environment
- .NET: MAUI (.NET version used in repro)
- MAUI: (same as repro)
- SkiaSharp / SkiaSharp.Views.Maui: (same as repro)
Additional context
- The repro uses a custom weak-reference based leak detector (
VisualLeakCheckQueue) - The leak occurs even with simple navigation and without specific user interaction
- I created a fork and implemented fixes that resolve the leak on all three platforms
(WinUI / Android / iOS) - I can open a Pull Request once we agree on the approach
Please let me know if you would like the repro simplified further (e.g. map without layers).