Leak canary, Recyclerview leaking mAdapter

前端 未结 4 1281
我寻月下人不归
我寻月下人不归 2021-01-30 16:33

I decided it was high time I learned how to use Leak Canary to detect Leaks within my apps, and as I always do, I tried to implement it in my project to really understand how to

4条回答
  •  自闭症患者
    2021-01-30 17:26

    I was able to fix this by overriding RecyclerView. It happens because RecyclerView never unregisters itself from AdapterDataObservable.

    @Override protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        if (getAdapter() != null) {
            setAdapter(null);
        }
    }
    

提交回复
热议问题