Closed keyfun closed 5 years ago
When i change fragment and destroy the Location Scene , leak Canary detected memory leak as below:
As i see, the DeviceLocation kept the context and cannot release it.
LocationManager$ListenerTransport.!(mListener)!
↳ DeviceLocation.!(locationScene)!
↳ LocationScene.!(mArSceneView)!
↳ ArSceneView.scene
↳ Scene.onUpdateListeners
↳ ArrayList.elementData
↳ array Object[].[0]
↳ BaseArFragment.mParentFragment
↳ NearbyArFragment
Reference Key: 91f6f2ca-6c27-4368-8491-2cbbb991d6b3
Device: Google google Pixel 2 walleye
Android Version: 9 API: 28 LeakCanary: 1.6.1 26145bf
Durations: watch=37758ms, gc=232ms, heap dump=5463ms, analysis=13553ms
Details:
Instance of android.location.LocationManager$ListenerTransport | static $class$accessFlags = 524288 | static $class$clinitThreadId = 0 | static $class$iFields = 1887405196 | static $class$shadow$klass = java.lang.Class | static $class$extData = null | static TYPE_PROVIDER_ENABLED = 3 | static $class$classFlags = 0 | static $class$status = -536870912 | static $class$primitiveType = 131072 | static $class$componentType = null | static $class$dexClassDefIndex = 6106 | static $class$numReferenceStaticFields = 0 | static $class$objectSizeAllocFastPath = 40 | static $class$ifTable = java.lang.Object[6]@1881876984 (0x702b29f8) | static $classOverhead = byte[260]@1884085377 (0x704cdc81) | static $class$referenceInstanceOffsets = 115 | static $class$vtable = null | static $class$superClass = android.location.ILocationListener$Stub | static $class$objectSize = 36 | static TYPE_LOCATION_CHANGED = 1 | static $class$name = "android.location.LocationManager$ListenerTransport" | static $class$methods = 1889491448 | static $class$dexCache = java.lang.DexCache@1881440488 (0x702480e8) | static $class$shadow$monitor = 536870912 | static TYPE_PROVIDER_DISABLED = 4 | static $class$classSize = 400 | static $class$sFields = 1887405128 | static $class$classLoader = null | static TYPE_STATUS_CHANGED = 2 | static $class$copiedMethodsOffset = 7 | static $class$numReferenceInstanceFields = 3 | static $class$dexTypeIndex = 4148 | static $class$virtualMethodsOffset = 3 | mListener = uk.co.appoly.arcorelocation.sensor.DeviceLocation@322418840 (0x1337b898) | mListenerHandler = android.location.LocationManager$ListenerTransport$1@323097032 (0x134211c8) | this$0 = android.location.LocationManager@322283480 (0x1335a7d8) | mDescriptor = "android.location.ILocationListener" | mObject = 491292479104 | mOwner = android.location.LocationManager$ListenerTransport@319361744 (0x130912d0) | shadow$klass = android.location.LocationManager$ListenerTransport | shadow$monitor = 0
Instance of uk.co.appoly.arcorelocation.sensor.DeviceLocation | static $class$accessFlags = 524289 | static $class$clinitThreadId = 21998 | static $class$iFields = 491249553664 | static $class$shadow$klass = java.lang.Class | static $class$extData = null | static $class$classFlags = 0 | static $class$status = -536870912 | static $class$primitiveType = 131072 | static $class$componentType = null | static $class$dexClassDefIndex = 1799 | static $class$numReferenceStaticFields = 0 | static $class$objectSizeAllocFastPath = 24 | static $class$ifTable = java.lang.Object[2]@320936088 (0x13211898) | static $classOverhead = byte[140]@320747825 (0x131e3931) | static $class$referenceInstanceOffsets = 7 | static $class$vtable = null | static $class$superClass = java.lang.Object | static $class$objectSize = 20 | static $class$name = null | static $class$methods = 491249553720 | static $class$dexCache = java.lang.DexCache@320432768 (0x13196a80) | static $class$shadow$monitor = 0 | static $class$classSize = 268 | static $class$sFields = 491249553640 | static $class$classLoader = dalvik.system.PathClassLoader@319157456 (0x1305f4d0) | static $class$copiedMethodsOffset = 8 | static $class$numReferenceInstanceFields = 3 | static TWO_MINUTES = 120000 | static $class$dexTypeIndex = 5899 | static $class$virtualMethodsOffset = 3 | currentBestL
When i change fragment and destroy the Location Scene , leak Canary detected memory leak as below:
As i see, the DeviceLocation kept the context and cannot release it.
LocationManager$ListenerTransport.!(mListener)!
↳ DeviceLocation.!(locationScene)!
↳ LocationScene.!(mArSceneView)!
↳ ArSceneView.scene
↳ Scene.onUpdateListeners
↳ ArrayList.elementData
↳ array Object[].[0]
↳ BaseArFragment.mParentFragment
↳ NearbyArFragment
Reference Key: 91f6f2ca-6c27-4368-8491-2cbbb991d6b3
Device: Google google Pixel 2 walleye
Android Version: 9 API: 28 LeakCanary: 1.6.1 26145bf
Durations: watch=37758ms, gc=232ms, heap dump=5463ms, analysis=13553ms
Details:
Instance of android.location.LocationManager$ListenerTransport | static $class$accessFlags = 524288 | static $class$clinitThreadId = 0 | static $class$iFields = 1887405196 | static $class$shadow$klass = java.lang.Class | static $class$extData = null | static TYPE_PROVIDER_ENABLED = 3 | static $class$classFlags = 0 | static $class$status = -536870912 | static $class$primitiveType = 131072 | static $class$componentType = null | static $class$dexClassDefIndex = 6106 | static $class$numReferenceStaticFields = 0 | static $class$objectSizeAllocFastPath = 40 | static $class$ifTable = java.lang.Object[6]@1881876984 (0x702b29f8) | static $classOverhead = byte[260]@1884085377 (0x704cdc81) | static $class$referenceInstanceOffsets = 115 | static $class$vtable = null | static $class$superClass = android.location.ILocationListener$Stub | static $class$objectSize = 36 | static TYPE_LOCATION_CHANGED = 1 | static $class$name = "android.location.LocationManager$ListenerTransport" | static $class$methods = 1889491448 | static $class$dexCache = java.lang.DexCache@1881440488 (0x702480e8) | static $class$shadow$monitor = 536870912 | static TYPE_PROVIDER_DISABLED = 4 | static $class$classSize = 400 | static $class$sFields = 1887405128 | static $class$classLoader = null | static TYPE_STATUS_CHANGED = 2 | static $class$copiedMethodsOffset = 7 | static $class$numReferenceInstanceFields = 3 | static $class$dexTypeIndex = 4148 | static $class$virtualMethodsOffset = 3 | mListener = uk.co.appoly.arcorelocation.sensor.DeviceLocation@322418840 (0x1337b898) | mListenerHandler = android.location.LocationManager$ListenerTransport$1@323097032 (0x134211c8) | this$0 = android.location.LocationManager@322283480 (0x1335a7d8) | mDescriptor = "android.location.ILocationListener" | mObject = 491292479104 | mOwner = android.location.LocationManager$ListenerTransport@319361744 (0x130912d0) | shadow$klass = android.location.LocationManager$ListenerTransport | shadow$monitor = 0
Instance of uk.co.appoly.arcorelocation.sensor.DeviceLocation | static $class$accessFlags = 524289 | static $class$clinitThreadId = 21998 | static $class$iFields = 491249553664 | static $class$shadow$klass = java.lang.Class | static $class$extData = null | static $class$classFlags = 0 | static $class$status = -536870912 | static $class$primitiveType = 131072 | static $class$componentType = null | static $class$dexClassDefIndex = 1799 | static $class$numReferenceStaticFields = 0 | static $class$objectSizeAllocFastPath = 24 | static $class$ifTable = java.lang.Object[2]@320936088 (0x13211898) | static $classOverhead = byte[140]@320747825 (0x131e3931) | static $class$referenceInstanceOffsets = 7 | static $class$vtable = null | static $class$superClass = java.lang.Object | static $class$objectSize = 20 | static $class$name = null | static $class$methods = 491249553720 | static $class$dexCache = java.lang.DexCache@320432768 (0x13196a80) | static $class$shadow$monitor = 0 | static $class$classSize = 268 | static $class$sFields = 491249553640 | static $class$classLoader = dalvik.system.PathClassLoader@319157456 (0x1305f4d0) | static $class$copiedMethodsOffset = 8 | static $class$numReferenceInstanceFields = 3 | static TWO_MINUTES = 120000 | static $class$dexTypeIndex = 5899 | static $class$virtualMethodsOffset = 3 | currentBestL