Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Android memory allocation growing infinitly

$
0
0

I have been trying to figure out how to create android apps that includes navigation and images, it seems that Xamarin.Forms keeps the images on memory even if you leave the page. Not only that it doesn't recognize that the same image is already loaded in the memory.

So this is too obvious to be a bug so I imagine I'm doing something wrong, can somebody help me to understand how to fix this simple app that describes the problem I have?

namespace RandomApp
{
    public class App
    {
        public static Page GetMainPage()
        {
            var testPage = new ContentPage(){
                Title = "First Page"
            };

            var testPageButton = new Button(){
                Text = "Next Page"
            };

            testPageButton.Clicked += async (object sender, EventArgs e) => {
                await testPage.Navigation.PushAsync(new ContentPage(){
                    Title = "Second Page",
                    Content = new StackLayout(){
                        Children = {new Image(){Source = ImageSource.FromFile("random_image.jpg")}}
                    }
                });
            };

            testPage.Content = new StackLayout{
                Children = {testPageButton}
            };

            return new NavigationPage(testPage); 
        }
    }
}

Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>