gpt4 book ai didi

android - LeakCanary 没有提供足够的信息来识别泄漏

转载 作者:行者123 更新时间:2023-12-04 07:57:54 36 4
gpt4 key购买 nike

我正在使用 LeakCanary,但堆分析结果没有提供足够的信息来检测任何泄漏。它只提到 Activity 正在泄漏。

D/LeakCanary: ​
====================================
HEAP ANALYSIS RESULT
====================================
1 APPLICATION LEAKS

References underlined with "~~~" are likely causes.
Learn more at https://squ.re/leaks.

298153 bytes retained by leaking objects
Signature: a610bac3ef989ac5dc5a69244fc2882de5617
┬───
│ GC Root: System class

├─ android.provider.FontsContract class
│ Leaking: NO (MyApplication↓ is not leaking and a class is never leaking)
│ ↓ static FontsContract.sContext
├─ com.example.MyApplication instance
│ Leaking: NO (Application is a singleton)
│ mBoundService instance of com.example.services.SessionService
│ mBase instance of android.app.ContextImpl
│ ↓ Application.mLoadedApk
│ ~~~~~~~~~~
├─ android.app.LoadedApk instance
│ Leaking: UNKNOWN
│ Retaining 302.8 kB in 4641 objects
│ mApplication instance of com.example.MyApplication
│ ↓ LoadedApk.mReceivers
│ ~~~~~~~~~~
├─ android.util.ArrayMap instance
│ Leaking: UNKNOWN
│ Retaining 301.7 kB in 4615 objects
│ ↓ ArrayMap.mArray
│ ~~~~~~
├─ java.lang.Object[] array
│ Leaking: UNKNOWN
│ Retaining 301.7 kB in 4613 objects
│ ↓ Object[].[2]
│ ~~~
╰→ com.example.activities.SelectActivity instance
​ Leaking: YES (ObjectWatcher was watching this because com.example.activities.SelectActivity received
​ Activity#onDestroy() callback and Activity#mDestroyed is true)
​ Retaining 298.2 kB in 4579 objects
​ key = 68660c30-bc17-4a74-a5e2-c54f6d676c59
​ watchDurationMillis = 5185
​ retainedDurationMillis = 183
​ mApplication instance of com.example.MyApplication
​ mBase instance of androidx.appcompat.view.ContextThemeWrapper
====================================
0 LIBRARY LEAKS

我从这个跟踪中知道的是 SelectActivity 正在泄漏。但我想不通为什么?该 Activity 本身有 1000 多行,我希望除了遍历每一行并检查可能的泄漏候选之外是否有任何捷径。

最佳答案

Activity 是否注册任何广播接收器?泄漏跟踪显示 LoadedApk.mReceivers,它是接收器到接收器调度器的 ArrayMap, Activity 是接收器调度器。

关于android - LeakCanary 没有提供足够的信息来识别泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66611127/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com