Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Xamarin - preventing memory leaks in ViewHolder & Adapter pattern

$
0
0

We are managing references in our ViewHolder in a following way:

public class MusicListViewHolder : Java.Lang.Object, IImageLoadingListener, View.IOnClickListener
    {
        public static readonly float COVER_ART_THUMB_SIZE_PX = 90;

        public delegate void OptionSelectedDelegate(object item);
        public delegate void PlayPauseClickDelegate(object item);

        private TextView m_title;
        private TextView m_subtitle;
        private TextView m_infoRow;
        private ImageView m_art;
        private ImageView m_downloadState;
        private RelativeLayout m_optionRelativeLayout;
        private ImageView m_optionImageView;

The worry I am having is that this looks a little like as a memory leak as we do not dispose the referenced TextViews and ImageViews anywhere. As I learnt when working with Xamarin everything should be properly disposed.

Are these references somehow magically destroyed by the adapter? Does this actually leak? The only suitable method to override that I found was:

protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }

Should I call m_title.Dispose() etc. in the override of protected override void Dispose(bool disposing)? Or is there anything else to this that I am missing?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



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