1

我有一个使用单个 Activity 和 Toothpick / Ktp 实现的应用程序。

我为每个片段创建一个范围,当片段被销毁时我关闭它。此行为在 BaseFragment 类中完成。

它确实使用 ViewBinding。

调用 onDestroyedView 时,适配器及其侦听器为空。

有人有其他想法这种泄漏可能来自哪里?或详细搜索?

┬───
│ GC Root: Global variable in native code
│
├─ toothpick.Toothpick class
│    Leaking: NO (HomeFragment↓ is not leaking and a class is never leaking)
│    ↓ static Toothpick.MAP_KEY_TO_SCOPE
├─ java.util.concurrent.ConcurrentHashMap instance
│    Leaking: NO (HomeFragment↓ is not leaking)
│    ↓ ConcurrentHashMap.table
├─ java.util.concurrent.ConcurrentHashMap$Node[] array
│    Leaking: NO (HomeFragment↓ is not leaking)
│    ↓ ConcurrentHashMap$Node[].[5]
├─ java.util.concurrent.ConcurrentHashMap$Node instance
│    Leaking: NO (HomeFragment↓ is not leaking)
│    ↓ ConcurrentHashMap$Node.key
├─ com.surprise.feature.home.presentation.HomeFragment instance
│    Leaking: NO (Fragment#mFragmentManager is not null)
│    ↓ HomeFragment.mLifecycleRegistry
│                   ~~~~~~~~~~~~~~~~~~
├─ androidx.lifecycle.LifecycleRegistry instance
│    Leaking: UNKNOWN
│    ↓ LifecycleRegistry.mObserverMap
│                        ~~~~~~~~~~~~
├─ androidx.arch.core.internal.FastSafeIterableMap instance
│    Leaking: UNKNOWN
│    ↓ FastSafeIterableMap.mHashMap
│                          ~~~~~~~~
├─ java.util.HashMap instance
│    Leaking: UNKNOWN
│    ↓ HashMap.table
│              ~~~~~
├─ java.util.HashMap$Node[] array
│    Leaking: UNKNOWN
│    ↓ HashMap$Node[].[8]
│                     ~~~
├─ java.util.HashMap$Node instance
│    Leaking: UNKNOWN
│    ↓ HashMap$Node.key
│                   ~~~
├─ androidx.viewpager2.adapter.FragmentStateAdapter$5 instance
│    Leaking: UNKNOWN
│    Anonymous class implementing androidx.lifecycle.LifecycleEventObserver
│    ↓ FragmentStateAdapter$5.this$0
│                             ~~~~~~
├─ com.surprise.common.presentation.view.adapter.PagerAdapter instance
│    Leaking: UNKNOWN
│    ↓ PagerAdapter.mFragments
│                   ~~~~~~~~~~
├─ androidx.collection.LongSparseArray instance
│    Leaking: UNKNOWN
│    ↓ LongSparseArray.mValues
│                      ~~~~~~~
├─ java.lang.Object[] array
│    Leaking: UNKNOWN
│    ↓ Object[].[0]
│               ~~~
╰→ com.surprise.feature.section.presentation.SectionFragment instance
​     Leaking: YES (ObjectWatcher was watching this because com.surprise.feature.section.presentation.SectionFragment received Fragment#onDestroy() callback and Fragment#mFragmentManager is null)
​     key = a4fbee3f-a0a2-464d-93ef-ae22a962a337
​     watchDurationMillis = 126195
​     retainedDurationMillis = 121174

METADATA

Build.VERSION.SDK_INT: 29
Build.MANUFACTURER: Google
LeakCanary version: 2.4
App process name: com.surprise.qual.pushdev.debug
Analysis duration: 622822 ms
4

0 回答 0