Android Realm - RealmBaseAdapter memory issue

232 views Asked by At

I have a memory issue with my RealmBaseAdapter. The problem is that the memory increases when a new row of the ListView is created and when the system needs to release memory it seems it destroys my "comercios" RealmResults and the app crash when I scroll the list. I'm not very sure what is happening. Thanks in advance.

My code:

public class ComercioAdapter extends RealmBaseAdapter<Comercio> implements ListAdapter {

    public ComercioAdapter(Context context, RealmResults<Comercio> comercios) {
        super(context, comercios, false);
    }

    public void reloadData(RealmResults<Comercio> comercios){
        this.realmResults = comercios;
        notifyDataSetChanged();
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;

        if (view == null) {
            view = ((Activity) context).getLayoutInflater().inflate(R.layout.adapter_comercio, null);
            holder = new ViewHolder();
            holder.name = (TextView) view.findViewById(R.id.name);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        Comercio comercio = getItem(i);
        holder.name.setText(comercio.getName());
        return view;
    }

    private class ViewHolder {
        private TextView name;
    }
}

Error log: 06-09 20:12:01.511 4406-4406/com.cmrlife.development A/libc﹕ Fatal signal 11 (SIGSEGV) at 0x00f600f2 (code=1), thread 4406

0

There are 0 answers