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

Should Pages be Disposable?

$
0
0

There seems to be a little bit of issue with pages not being released when their popped. I'm wondering if pages should implement IDisposable?

I posted a comment here, and I wonder if it would work with the current implementation of Xamarin.Forms... IE: would Pop actually call Dispose?

This is just a thought....

public class SecondPage : ContentPage
{
    private Image _img;

    public SecondPage()
    {
        _img = new Image {Source = new FileImageSource {File = "largeImage.jpg"}};

        Content = _img;
    }

    protected override void Dispose() // overrides the base Dispose because [ Page : IDisposable ]
    {
        base.Dispose();

        _img.Source = null;
        _img = null;

        GC.Collect();
    }
}

Viewing all articles
Browse latest Browse all 89864

Trending Articles



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