mrmans0n / smart-location-lib

Android library project that lets you manage the location updates to be as painless as possible
1.65k stars 353 forks source link

Memory Leak android.app.ServiceConnectionLeaked #155

Open rohankandwal opened 8 years ago

rohankandwal commented 8 years ago

We are using LeakCanary to find bugs in our app and have found a leak in the latest build '3.2.5'. Following are the logs -

08-12 17:33:57.853 20505-20520/com.example D/LeakCanary: Could not dump heap, previous analysis still is in progress.
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: In com.example:2.11:22.
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * com.example.ui.SplashScreen has leaked:
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * GC ROOT android.app.LoadedApk$ServiceDispatcher$DeathMonitor.this$1
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * references android.app.LoadedApk$ServiceDispatcher.mConnection
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * references com.google.android.gms.common.internal.zzn$zzb$zza.yL
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * references com.google.android.gms.common.internal.zzn$zzb.yH
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * references java.util.HashSet.backingMap
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * references java.util.HashMap.table
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * references array java.util.HashMap$HashMapEntry[].[0]
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * references java.util.HashMap$HashMapEntry.key
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * references com.google.android.gms.common.internal.zzd$zzh.xv
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * references com.google.android.gms.location.internal.zzl.mContext
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * leaks com.example.ui.SplashScreen instance
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * Retaining: 17 MB.
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * Reference Key: 9409add5-92b3-4969-ab10-86c9b1cad4c9
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * Device: YU YU AO5510 YUREKA
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * Android Version: 6.0.1 API: 23 LeakCanary: 1.4-beta2 3799172
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * Durations: watch=5035ms, gc=214ms, heap dump=37410ms, analysis=90577ms
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * Details:
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * Instance of android.app.LoadedApk$ServiceDispatcher$DeathMonitor
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: |   mName = android.content.ComponentName@316108992 (0x12d770c0)
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: |   mService = android.os.BinderProxy@316085504 (0x12d71500)
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: |   this$1 = android.app.LoadedApk$ServiceDispatcher@316814096 (0x12e23310)
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: |   shadow$_klass_ = android.app.LoadedApk$ServiceDispatcher$DeathMonitor
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: |   shadow$_monitor_ = 0
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: * Instance of android.app.LoadedApk$ServiceDispatcher
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: |   mActiveConnections = android.util.ArrayMap@316809952 (0x12e222e0)
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: |   mActivityThread = android.app.ActivityThread$H@316084992 (0x12d71300)
08-12 17:34:28.090 20505-23181/com.example D/LeakCanary: |   mConnection = com.google.android.gms.common.internal.zzn$zzb$zza@317485472 (0x12ec71a0)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   mContext = com.example.exampleApplication@316292880 (0x12da3f10)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   mDied = false
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   mFlags = 129
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   mForgotten = false
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   mIServiceConnection = android.app.LoadedApk$ServiceDispatcher$InnerConnection@316809984 (0x12e22300)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   mLocation = android.app.ServiceConnectionLeaked@316810048 (0x12e22340)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   mUnbindLocation = null
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   shadow$_klass_ = android.app.LoadedApk$ServiceDispatcher
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   shadow$_monitor_ = 0
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: * Instance of com.google.android.gms.common.internal.zzn$zzb$zza
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   yL = com.google.android.gms.common.internal.zzn$zzb@316813952 (0x12e23280)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   shadow$_klass_ = com.google.android.gms.common.internal.zzn$zzb$zza
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   shadow$_monitor_ = -2073104422
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: * Instance of com.google.android.gms.common.internal.zzn$zzb
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   mState = 1
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   xA = android.os.BinderProxy@316085504 (0x12d71500)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   yF = android.content.ComponentName@316108992 (0x12d770c0)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   yG = com.google.android.gms.common.internal.zzn$zzb$zza@317485472 (0x12ec71a0)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   yH = java.util.HashSet@317485488 (0x12ec71b0)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   yI = true
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   yJ = com.google.android.gms.common.internal.zzn$zza@316809760 (0x12e22220)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   yK = com.google.android.gms.common.internal.zzn@316748960 (0x12e134a0)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   shadow$_klass_ = com.google.android.gms.common.internal.zzn$zzb
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   shadow$_monitor_ = 0
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: * Instance of java.util.HashSet
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   static $staticOverhead = byte[8]@1878227401 (0x6ff379c9)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   static serialVersionUID = -5024744406713321676
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   backingMap = java.util.HashMap@316814000 (0x12e232b0)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   shadow$_klass_ = java.util.HashSet
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   shadow$_monitor_ = 0
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: * Instance of java.util.HashMap
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   static MINIMUM_CAPACITY = 4
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   static serialPersistentFields = java.io.ObjectStreamField[1]@1877403456 (0x6fe6e740)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   static EMPTY_TABLE = java.util.HashMap$HashMapEntry[2]@1877403000 (0x6fe6e578)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   static serialVersionUID = 362498820763181265
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   static $staticOverhead = byte[48]@1878226449 (0x6ff37611)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   static MAXIMUM_CAPACITY = 1073741824
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   static DEFAULT_LOAD_FACTOR = 0.75
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   entryForNullKey = null
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   entrySet = null
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   keySet = java.util.HashMap$KeySet@319780256 (0x130f75a0)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   modCount = 2
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   size = 2
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   table = java.util.HashMap$HashMapEntry[4]@316809888 (0x12e222a0)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   threshold = 3
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   values = null
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   keySet = null
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   valuesCollection = null
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   shadow$_klass_ = java.util.HashMap
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   shadow$_monitor_ = 0
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: * Array of java.util.HashMap$HashMapEntry[]
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   [0] = java.util.HashMap$HashMapEntry@316809920 (0x12e222c0)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   [1] = java.util.HashMap$HashMapEntry@317387456 (0x12eaf2c0)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   [2] = null
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   [3] = null
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: * Instance of java.util.HashMap$HashMapEntry
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   hash = -18079104
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   key = com.google.android.gms.common.internal.zzd$zzh@317485456 (0x12ec7190)
08-12 17:34:28.091 20505-23181/com.example D/LeakCanary: |   next = null
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   value = java.util.HashSet@317485488 (0x12ec71b0)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   shadow$_klass_ = java.util.HashMap$HashMapEntry
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   shadow$_monitor_ = 0
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: * Instance of com.google.android.gms.common.internal.zzd$zzh
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xv = com.google.android.gms.location.internal.zzl@314710608 (0x12c21a50)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xy = 0
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   shadow$_klass_ = com.google.android.gms.common.internal.zzd$zzh
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   shadow$_monitor_ = -2097977979
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: * Instance of com.google.android.gms.location.internal.zzl
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   adR = com.google.android.gms.location.internal.zzk@316750464 (0x12e13a80)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   adx = java.lang.String@316771680 (0x12e18d60)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   ady = com.google.android.gms.location.internal.zzb$1@317204704 (0x12e828e0)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   aP = null
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   dY = java.util.Collections$UnmodifiableSet@317204544 (0x12e82840)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   tD = com.google.android.gms.common.internal.zzg@316722912 (0x12e0cee0)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   mContext = com.example.ui.SplashScreen@315003136 (0x12c69100)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   mHandler = com.google.android.gms.common.internal.zzd$zzd@316749504 (0x12e136c0)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   tp = com.google.android.gms.common.GoogleApiAvailability@317204240 (0x12e82710)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xb = 0
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xc = 0
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xd = 1471003325968
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xe = 0
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xf = 0
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xg = com.google.android.gms.common.internal.zzn@316748960 (0x12e134a0)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xh = java.lang.Object@317204640 (0x12e828a0)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xi = com.google.android.gms.common.internal.zzu$zza$zza@319780288 (0x130f75c0)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xj = com.google.android.gms.internal.zzqb$zza@316802112 (0x12e20440)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xk = com.google.android.gms.location.internal.zzi$zza$zza@319780608 (0x130f7700)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xl = java.util.ArrayList@316749472 (0x12e136a0)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xm = com.google.android.gms.common.internal.zzd$zzh@317485456 (0x12ec7190)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xn = 3
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xo = com.google.android.gms.common.internal.zzk$1@317204592 (0x12e82870)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xp = com.google.android.gms.common.internal.zzk$2@317204608 (0x12e82880)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xq = 23
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xr = java.lang.String@322305808 (0x1335ff10)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   xs = java.util.concurrent.atomic.AtomicInteger@317204656 (0x12e828b0)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   zzahv = android.os.Looper@316084896 (0x12d712a0)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   zzail = java.lang.Object@317204624 (0x12e82890)
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   shadow$_klass_ = com.google.android.gms.location.internal.zzl
08-12 17:34:28.092 20505-23181/com.example D/LeakCanary: |   shadow$_monitor_ = -2034954257

Following are my 'build.gradle' settings

 //Other libraries
    compile 'com.google.android.gms:play-services-location:9.2.1'
    compile 'com.google.android.gms:play-services-places:9.2.1'
    compile 'com.google.android.gms:play-services-analytics:9.2.1'
    compile 'com.google.android.gms:play-services-gcm:9.2.1'
    compile 'io.nlopez.smartlocation:library:3.2.5'

This is causing 17 Mb to be leaked from memory. Is there anything I can do to get rid of this issue?

droidster commented 8 years ago

@rohankandwal Could you post the code as well?