How to fix Dialog Fragment memory leak?

Viewed 133

I'm trying to destroy my dialog fragment but after onDestroy is called leakcanary notification is appeared and this log print for me.

I take this error with BottomSheetDialogFragment too.

I'm setting all object nullable and destroy all of them in onDestroyView

┬───
│ GC Root: Thread object
│
├─ com.google.maps.api.android.lib6.gmm6.vector.n instance
│    Leaking: NO (ac↓ is not leaking)
│    Thread name: 'RenderDrive'
│    ↓ n.e
├─ com.google.maps.api.android.lib6.gmm6.vector.p instance
│    Leaking: NO (ac↓ is not leaking)
│    ↓ p.f
├─ com.google.maps.api.android.lib6.gmm6.api.ac instance
│    Leaking: NO (RecyclerView↓ is not leaking and View attached)
│    View is part of a window view hierarchy
│    View.mAttachInfo is not null (view attached)
│    View.mWindowAttachCount = 1
│    mContext instance of app.delivery.client.AndroidApplication
│    ↓ View.mAttachInfo
├─ android.view.View$AttachInfo instance
│    Leaking: NO (RecyclerView↓ is not leaking)
│    ↓ View$AttachInfo.mScrollContainers
├─ java.util.ArrayList instance
│    Leaking: NO (RecyclerView↓ is not leaking)
│    ↓ ArrayList[1]
├─ androidx.recyclerview.widget.RecyclerView instance
│    Leaking: NO (MainFragment↓ is not leaking and View attached)
│    View is part of a window view hierarchy
│    View.mAttachInfo is not null (view attached)
│    View.mID = R.id.tabLayout
│    View.mWindowAttachCount = 1
│    mContext instance of app.delivery.client.features.MainActivity.View.
│    MainActivity with mDestroyed = false
│    ↓ RecyclerView.mAdapter
├─ app.delivery.client.features.Main.Main.Adapter.TabAdapter instance
│    Leaking: NO (MainFragment↓ is not leaking)
│    ↓ TabAdapter.iSelectTab
├─ app.delivery.client.features.Main.Main.View.MainFragment instance
│    Leaking: NO (ProfileFragment↓ is not leaking and Fragment#mFragmentManager
│    is not null)
│    parentActivity instance of app.delivery.client.features.MainActivity.View.
│    MainActivity with mDestroyed = false
│    ↓ MainFragment.profileFragment
├─ app.delivery.client.features.Main.Main.Profile.View.ProfileFragment instance
│    Leaking: NO (Fragment#mFragmentManager is not null)
│    parentActivity instance of app.delivery.client.features.MainActivity.View.
│    MainActivity with mDestroyed = false
│    ↓ ProfileFragment.addBalanceDialog
│                      ~~~~~~~~~~~~~~~~
╰→ app.delivery.client.features.Main.AddBalance.View.AddBalanceDialog instance
​     Leaking: YES (ObjectWatcher was watching this because app.delivery.client.
​     features.Main.AddBalance.View.AddBalanceDialog received
​     Fragment#onDestroy() callback and Fragment#mFragmentManager is null)
​     Retaining 3.3 kB in 101 objects
​     key = 9f9e28af-1fdf-4810-9940-26735e1b2d1d
​     watchDurationMillis = 39126
​     retainedDurationMillis = 34125


0 Answers
Related