android-samples icon indicating copy to clipboard operation
android-samples copied to clipboard

Memory leak in LiteListDemoActivity

Open ljarka opened this issue 2 years ago • 1 comments

I added LeakCanary to sample app, played around with LiteListDemoActivity and leak canary detects a lot of leaks in this activity.

Environment details

Build.VERSION.SDK_INT: 29
Build.MANUFACTURER: samsung
LeakCanary version: 2.8.1
App process name: com.example.kotlindemos.gms

Steps to reproduce

  1. Add LeakCanary library to app
  2. Open LiteListDemo
  3. Move back to list of samples
  4. Wait for a report from LeakCanary

Stack trace

┬───
 │ GC Root: Global variable in native code
 │
 ├─ ft instance
 │    Leaking: UNKNOWN
 │    Retaining 2.0 kB in 49 objects
 │    ↓ ft.a
 │         ~
 ├─ fu instance
 │    Leaking: UNKNOWN
 │    Retaining 1.5 kB in 48 objects
 │    ↓ fu.g
 │         ~
 ├─ er instance
 │    Leaking: UNKNOWN
 │    Retaining 1.3 kB in 39 objects
 │    ↓ er.a
 │         ~
 ├─ eu instance
 │    Leaking: UNKNOWN
 │    Retaining 96 B in 6 objects
 │    e instance of androidx.multidex.MultiDexApplication
 │    ↓ eu.d
 │         ~
 ├─ com.google.maps.api.android.lib6.impl.ew instance
 │    Leaking: UNKNOWN
 │    Retaining 16 B in 1 objects
 │    ↓ ew.b
 │         ~
 ├─ com.google.maps.api.android.lib6.impl.ec instance
 │    Leaking: UNKNOWN
 │    Retaining 2.9 MB in 26412 objects
 │    s instance of androidx.multidex.MultiDexApplication
 │    ↓ ec.t
 │         ~
 ├─ java.util.ArrayList instance
 │    Leaking: UNKNOWN
 │    Retaining 2.9 MB in 26390 objects
 │    ↓ ArrayList[0]
 │               ~~~
 ├─ com.google.maps.api.android.lib6.lite.b instance
 │    Leaking: UNKNOWN
 │    Retaining 27.8 kB in 166 objects
 │    ↓ b.b
 │        ~
 ├─ com.google.maps.api.android.lib6.lite.h instance
 │    Leaking: UNKNOWN
 │    Retaining 27.8 kB in 165 objects
 │    ↓ h.c
 │        ~
 ├─ com.google.maps.api.android.lib6.lite.i instance
 │    Leaking: UNKNOWN
 │    Retaining 24 B in 1 objects
 │    ↓ i.a
 │        ~
 ├─ com.google.maps.api.android.lib6.impl.ax instance
 │    Leaking: UNKNOWN
 │    Retaining 20 B in 1 objects
 │    a instance of androidx.multidex.MultiDexApplication
 │    b instance of com.example.kotlindemos.LiteListDemoActivity with mDestroyed = true
 │    ↓ ax.b
 │         ~
 ╰→ com.example.kotlindemos.LiteListDemoActivity instance
 ​     Leaking: YES (ObjectWatcher was watching this because com.example.kotlindemos.LiteListDemoActivity received
 ​     Activity#onDestroy() callback and Activity#mDestroyed is true)
 ​     Retaining 65.6 kB in 1274 objects
 ​     key = a5e2c6a2-7128-451c-916d-47876e3453c7
 ​     watchDurationMillis = 12553
 ​     retainedDurationMillis = 7552
 ​     mApplication instance of androidx.multidex.MultiDexApplication
 ​     mBase instance of androidx.appcompat.view.ContextThemeWrapper

ljarka avatar Jan 07 '22 12:01 ljarka

Thanks for reporting. Feel free to send us a PR for it!

arriolac avatar Jan 07 '22 17:01 arriolac