androidmemory-leaksleakcanary

Android leak canary - leaking empty activity


I'm getting notification as my activities are being leaked, even though activities are all empty.

here is the trace:

    ApplicationLeak(className=com.bcx.tracker.ui.login.LoginActivity, leakTrace=
    ┬
    ├─ android.app.Activity$1
    │    Leaking: UNKNOWN
    │    Anonymous subclass of android.app.IRequestFinishCallback$Stub
    │    GC Root: Global variable in native code
    │    ↓ Activity$1.this$0
    │                 ~~~~~~
    ╰→ com.bcx.tracker.ui.login.LoginActivity
    ​     Leaking: YES (Activity#mDestroyed is true and ObjectWatcher was watching this)
    ​     key = fc3d8e13-c51c-4ff8-995f-4e0da90f085b
    ​     watchDurationMillis = 7889
    ​     retainedDurationMillis = 2886
    ​     key = b809b94b-fd3c-4d26-bda4-7f175624c3c3
    , retainedHeapByteSize=166095)

I just added the dependency in build.gradle

    debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-3'

Is there anything that I'm missing here?.

i've gone through this stackoverflow link which didn't help.

My device:

OnePlus 7, android 10

Emulator , android 10


Solution

  • This is a known leak in the Android Framework in Android 10: https://issuetracker.google.com/issues/139738913