Skip to content

memory leak when there's an active navigation and the NavFragmentActivity is exited #18

@confused-again

Description

@confused-again

description:

build and run the provided navigation-sample project,
launch the demo NavFragmentActivity
click 'set destination' button and enter a city that's accessible (eg. Toronto)
allow the navigation simulation to start
go back (from the system action bar)
observe a memory leak.

question:
is this a valid memory leak detected by leakCanary? is there a workaround for this within the application or does the library need to be fixed?

logs:

01-08 11:41:30.857 24515 25171 D LeakCanary: ====================================
01-08 11:41:30.857 24515 25171 D LeakCanary: HEAP ANALYSIS RESULT
01-08 11:41:30.857 24515 25171 D LeakCanary: ====================================
01-08 11:41:30.857 24515 25171 D LeakCanary: 1 APPLICATION LEAKS
01-08 11:41:30.857 24515 25171 D LeakCanary:
01-08 11:41:30.857 24515 25171 D LeakCanary: References underlined with "~~~" are likely causes.
01-08 11:41:30.857 24515 25171 D LeakCanary: Learn more at https://squ.re/leaks.
01-08 11:41:30.857 24515 25171 D LeakCanary:
01-08 11:41:30.857 24515 25171 D LeakCanary: 3009052 bytes retained by leaking objects
01-08 11:41:30.857 24515 25171 D LeakCanary: Signature: 1c492f6be9580b9a9d8b8d1c3b7b6439a9fab1b0
01-08 11:41:30.857 24515 25171 D LeakCanary: ┬───
01-08 11:41:30.857 24515 25171 D LeakCanary: │ GC Root: Input or output parameters in native code
01-08 11:41:30.857 24515 25171 D LeakCanary: │
01-08 11:41:30.857 24515 25171 D LeakCanary: ├─ com.google.android.libraries.navigation.internal.fs.s instance
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Leaking: UNKNOWN
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Retaining 30 B in 1 objects
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ↓ s.c
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ~
01-08 11:41:30.857 24515 25171 D LeakCanary: ├─ com.google.android.libraries.navigation.internal.in.ac instance
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Leaking: UNKNOWN
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Retaining 1.7 kB in 60 objects
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ↓ a.e
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ~
01-08 11:41:30.857 24515 25171 D LeakCanary: ├─ java.util.concurrent.ConcurrentHashMap instance
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Leaking: UNKNOWN
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Retaining 1.4 kB in 48 objects
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ↓ ConcurrentHashMap[key()]
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ~~~~~~~
01-08 11:41:30.857 24515 25171 D LeakCanary: ├─ com.google.android.libraries.navigation.internal.in.a$a instance
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Leaking: UNKNOWN
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Retaining 17.2 kB in 261 objects
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ↓ a$a.b
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ~
01-08 11:41:30.857 24515 25171 D LeakCanary: ├─ java.util.concurrent.Executors$RunnableAdapter instance
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Leaking: UNKNOWN
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Retaining 17.1 kB in 260 objects
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ↓ Executors$RunnableAdapter.task
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ~~~~
01-08 11:41:30.857 24515 25171 D LeakCanary: ├─ com.google.android.libraries.navigation.internal.bo.ao instance
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Leaking: UNKNOWN
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Retaining 17.1 kB in 259 objects
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ↓ ao.a
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ~
01-08 11:41:30.857 24515 25171 D LeakCanary: ├─ com.google.android.libraries.navigation.internal.zd.bw instance
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Leaking: UNKNOWN
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Retaining 17.1 kB in 258 objects
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ↓ d.value
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ~~~~~
01-08 11:41:30.857 24515 25171 D LeakCanary: ├─ com.google.android.libraries.navigation.internal.cq.bw instance
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Leaking: UNKNOWN
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Retaining 17.1 kB in 257 objects
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ↓ bw.b
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ~
01-08 11:41:30.857 24515 25171 D LeakCanary: ├─ com.google.android.libraries.navigation.internal.nv.g instance
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Leaking: UNKNOWN
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Retaining 1.3 kB in 40 objects
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ↓ g.a
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ~
01-08 11:41:30.857 24515 25171 D LeakCanary: ├─ com.google.android.libraries.navigation.internal.ov.e instance
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Leaking: UNKNOWN
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Retaining 352 B in 11 objects
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ↓ e.g
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ~
01-08 11:41:30.857 24515 25171 D LeakCanary: ├─ com.google.android.libraries.navigation.internal.ov.d instance
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Leaking: UNKNOWN
01-08 11:41:30.857 24515 25171 D LeakCanary: │ Retaining 32 B in 1 objects
01-08 11:41:30.857 24515 25171 D LeakCanary: │ e instance of cerence.google.navigation.maps.sample.NavFragmentActivity with mDestroyed = true
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ↓ d.e
01-08 11:41:30.857 24515 25171 D LeakCanary: │ ~
01-08 11:41:30.857 24515 25171 D LeakCanary: ╰→ cerence.google.navigation.maps.sample.NavFragmentActivity instance
01-08 11:41:30.857 24515 25171 D LeakCanary: ​ Leaking: YES (ObjectWatcher was watching this because cerence.google.navigation.maps.sample.NavFragmentActivity
01-08 11:41:30.857 24515 25171 D LeakCanary: ​ received Activity#onDestroy() callback and Activity#mDestroyed is true)
01-08 11:41:30.857 24515 25171 D LeakCanary: ​ Retaining 3.0 MB in 39053 objects
01-08 11:41:30.857 24515 25171 D LeakCanary: ​ key = 1949e352-b12f-4843-959f-761514098dad
01-08 11:41:30.857 24515 25171 D LeakCanary: ​ watchDurationMillis = 5166
01-08 11:41:30.857 24515 25171 D LeakCanary: ​ retainedDurationMillis = 165
01-08 11:41:30.857 24515 25171 D LeakCanary: ​ mApplication instance of cerence.google.navigation.maps.sample.MainApp
01-08 11:41:30.857 24515 25171 D LeakCanary: ​ mBase instance of androidx.appcompat.view.ContextThemeWrapper
01-08 11:41:30.857 24515 25171 D LeakCanary: ====================================
01-08 11:41:30.857 24515 25171 D LeakCanary: 0 LIBRARY LEAKS
01-08 11:41:30.858 24515 25171 D LeakCanary:
01-08 11:41:30.858 24515 25171 D LeakCanary: A Library Leak is a leak caused by a known bug in 3rd party code that you do not have control over.
01-08 11:41:30.858 24515 25171 D LeakCanary: See https://square.github.io/leakcanary/fundamentals-how-leakcanary-works/#4-categorizing-leaks
01-08 11:41:30.858 24515 25171 D LeakCanary: ====================================
01-08 11:41:30.858 24515 25171 D LeakCanary: 0 UNREACHABLE OBJECTS
01-08 11:41:30.858 24515 25171 D LeakCanary:
01-08 11:41:30.858 24515 25171 D LeakCanary: An unreachable object is still in memory but LeakCanary could not find a strong reference path
01-08 11:41:30.858 24515 25171 D LeakCanary: from GC roots.
01-08 11:41:30.858 24515 25171 D LeakCanary: ====================================
01-08 11:41:30.858 24515 25171 D LeakCanary: METADATA
01-08 11:41:30.858 24515 25171 D LeakCanary:
01-08 11:41:30.858 24515 25171 D LeakCanary: Please include this in bug reports and Stack Overflow questions.
01-08 11:41:30.858 24515 25171 D LeakCanary:
01-08 11:41:30.858 24515 25171 D LeakCanary: Build.VERSION.SDK_INT: 33
01-08 11:41:30.858 24515 25171 D LeakCanary: Build.MANUFACTURER: samsung
01-08 11:41:30.858 24515 25171 D LeakCanary: LeakCanary version: 2.14
01-08 11:41:30.858 24515 25171 D LeakCanary: App process name: cerence.google.navigation.maps.sample
01-08 11:41:30.858 24515 25171 D LeakCanary: Class count: 45316
01-08 11:41:30.858 24515 25171 D LeakCanary: Instance count: 466652
01-08 11:41:30.858 24515 25171 D LeakCanary: Primitive array count: 264560
01-08 11:41:30.858 24515 25171 D LeakCanary: Object array count: 72531
01-08 11:41:30.858 24515 25171 D LeakCanary: Thread count: 92
01-08 11:41:30.858 24515 25171 D LeakCanary: Heap total bytes: 60020255
01-08 11:41:30.858 24515 25171 D LeakCanary: Bitmap count: 173
01-08 11:41:30.858 24515 25171 D LeakCanary: Bitmap total bytes: 1679625
01-08 11:41:30.858 24515 25171 D LeakCanary: Large bitmap count: 0
01-08 11:41:30.858 24515 25171 D LeakCanary: Large bitmap total bytes: 0
01-08 11:41:30.858 24515 25171 D LeakCanary: Db 1: closed /data/user/0/cerence.google.navigation.maps.sample/databases/ue3.db
01-08 11:41:30.858 24515 25171 D LeakCanary: Db 2: open /data/user/0/cerence.google.navigation.maps.sample/databases/com.google.android.datatransport.events
01-08 11:41:30.858 24515 25171 D LeakCanary: Db 3: open /storage/emulated/0/Android/data/cerence.google.navigation.maps.sample/files/databases/refapp_db.db
01-08 11:41:30.858 24515 25171 D LeakCanary: Count of retained yet cleared: 3 KeyedWeakReference instances
01-08 11:41:30.858 24515 25171 D LeakCanary: Stats: LruCache[maxSize=3000,hits=150357,misses=420528,hitRate=26%]
01-08 11:41:30.858 24515 25171 D LeakCanary: RandomAccess[bytes=22919200,reads=420528,travel=239592751161,range=65887122,size=84370020]
01-08 11:41:30.858 24515 25171 D LeakCanary: Heap dump reason: 6 retained objects, app is not visible
01-08 11:41:30.858 24515 25171 D LeakCanary: Analysis duration: 31995 ms
01-08 11:41:30.858 24515 25171 D LeakCanary: Heap dump file path: /storage/emulated/0/Download/leakcanary-cerence.google.navigation.maps.
01-08 11:41:30.858 24515 25171 D LeakCanary: sample/2025-01-08_11-40-54_063.hprof
01-08 11:41:30.858 24515 25171 D LeakCanary: Heap dump timestamp: 1736354490843
01-08 11:41:30.858 24515 25171 D LeakCanary: Heap dump duration: 2170 ms
01-08 11:41:30.858 24515 25171 D LeakCanary: ====================================

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions