When using a NavigationPage with a ContentPage that contains a map on Android and a button to navigate to a new page (of the same layout), navigating back and forth repeatedly will eventually cause an out of memory error.
## Reproduction steps
- Update API key as necessary for Google Play Services
- Run application
- Use the button to navigate forward to a new page, and navigate back as desired
- An out of memory error should eventually occur (testing an S5, it took maybe 25-30 pages or so).
Created attachment 15333 [details]
I have managed to fix the memory leak. I have subclassed the xamarin map renderer and in the Dispose method, instead of calling base.Dispose() I am calling the below (as well as the code in the current MapRenderer.Dispose method)
(this.Control as MapView).OnPause();
(this.Control as MapView).OnDestroy();
(this.Control as MapView).Dispose();
The issue is Xamarin aren't calling these in the dispose, so the view lives on in memory and causes memory leaks. So to fix, these need to be applied in the Dispose method of the MapRenderer at somne point
Do you mind sharing a sample project ? ty
Should be fixed in 2.3.4-pre1
I have checked this issue with Xamarin.Forms 2.3.4-pre1 and I am not getting any crash.
Hence closing this issue.