leandroBorgesFerreira / LoadingButtonAndroid

A button to substitute the ProgressDialog
MIT License
1.94k stars 214 forks source link

Memory leak on ver 2.2.0 #160

Open jonbhanson opened 4 years ago

jonbhanson commented 4 years ago

Thanks for a great component! I am getting a memory leak when I navigate away from a fragment that contains the Loading Button. I added a manual call to .dispose() in the fragment's onDestroyView, but that did not help.

Here is the LeakCanary dump:

┬─── │ GC Root: Global variable in native code │ ├─ com.google.android.gms.internal.location.zzat instance │ Leaking: NO (MainActivity↓ is not leaking) │ ↓ zzat.zzda ├─ com.google.android.gms.common.api.internal.ListenerHolder instance │ Leaking: NO (MainActivity↓ is not leaking) │ ↓ ListenerHolder.zajn ├─ app.xchangr.xchangr.MainActivity$14 instance │ Leaking: NO (MainActivity↓ is not leaking) │ Anonymous subclass of com.google.android.gms.location.LocationCallback │ ↓ MainActivity$14.this$0 ├─ app.xchangr.xchangr.MainActivity instance │ Leaking: NO (Activity#mDestroyed is false) │ ↓ MainActivity.mLifecycleRegistry │ ~~~~~~ ├─ androidx.lifecycle.LifecycleRegistry instance │ Leaking: UNKNOWN │ ↓ LifecycleRegistry.mObserverMap │ ~~~~ ├─ androidx.arch.core.internal.FastSafeIterableMap instance │ Leaking: UNKNOWN │ ↓ FastSafeIterableMap.mEnd │ ~~~~ ├─ androidx.arch.core.internal.SafeIterableMap$Entry instance │ Leaking: UNKNOWN │ ↓ SafeIterableMap$Entry.mKey │ ~~~~ ├─ br.com.simplepass.loadingbutton.customViews.CircularProgressButton instance │ Leaking: YES (View detached and has parent) │ mContext instance of app.xchangr.xchangr.MainActivity with mDestroyed = false │ View#mParent is set │ View#mAttachInfo is null (view detached) │ View.mID = R.id.buttonRequestConnect │ View.mWindowAttachCount = 1 │ ↓ CircularProgressButton.mParent ╰→ androidx.constraintlayout.widget.ConstraintLayout instance ​ Leaking: YES (ObjectWatcher was watching this because Fragment received Fragment#onDestroyView() callback (references to its views should be cleared to prevent leaks)) ​ key = 01466f2b-0b53-4b23-bc09-80d260275b35 ​ watchDurationMillis = 8923 ​ retainedDurationMillis = 3919 ​ key = 3a360067-4df8-48ec-a9a4-5cd12dce14d8 ​ watchDurationMillis = 8924 ​ retainedDurationMillis = 3921 ​ mContext instance MainActivity with mDestroyed = false ​ View#mParent is null ​ View#mAttachInfo is null (view detached) ​ View.mWindowAttachCount = 1

METADATA

Build.VERSION.SDK_INT: 29 Build.MANUFACTURER: Google LeakCanary version: 2.2

jmadaminov commented 4 years ago

Hi, thanx for the great library, but I'm also having memory leak, any updates on this?

MahdiNavidi commented 2 years ago

hi I had this problem too this solution resolved my problem https://github.com/leandroBorgesFerreira/LoadingButtonAndroid/issues/144#issuecomment-585668460