Closed tzrgaga closed 3 years ago
小伙子,Studio 的内存泄漏堆栈我看不出来是哪里的问题,麻烦给出 LeakCanary 堆栈的长截图。
HEAP ANALYSIS RESULT
====================================
1 APPLICATION LEAKS
References underlined with "~~~" are likely causes.
Learn more at https://squ.re/leaks.
11588 bytes retained by leaking objects
Signature: e1c76f0955a7d673de751fa83bd6a78af3abee8
┬───
│ GC Root: System class
│
├─ android.app.ActivityThread class
│ Leaking: NO (a class is never leaking)
│ ↓ static ActivityThread.sCurrentActivityThread
│ ~~~~~~~~~~~~~~~~~~~~~~
├─ android.app.ActivityThread instance
│ Leaking: UNKNOWN
│ Retaining 695.2 kB in 5281 objects
│ mInitialApplication instance of com.xintu.baomi.base.AppApplication
│ mSystemContext instance of android.app.ContextImpl
│ mSystemUiContext instance of android.app.ContextImpl
│ ↓ ActivityThread.mNewActivities
│ ~~~~~~~~~~~~~~
├─ android.app.ActivityThread$ActivityClientRecord instance
│ Leaking: UNKNOWN
│ Retaining 673.6 kB in 4855 objects
│ activity instance of com.xintu.baomi.app.login.MainActivity with mDestroyed = false
│ ↓ ActivityThread$ActivityClientRecord.nextIdle
│ ~~~~~~~~
├─ android.app.ActivityThread$ActivityClientRecord instance
│ Leaking: UNKNOWN
│ Retaining 672.7 kB in 4837 objects
│ activity instance of com.xintu.baomi.app.show.ui.activity.LivePreparationActivity with mDestroyed = true
│ ↓ ActivityThread$ActivityClientRecord.activity
│ ~~~~~~~~
╰→ com.xx.show.ui.activity.LivePreparationActivity instance
Leaking: YES (ObjectWatcher was watching this because com.xx.show.ui.activity.
LivePreparationActivity received Activity#onDestroy() callback and Activity#mDestroyed is true)
Retaining 11.6 kB in 376 objects
key = 7299ba45-b0b0-429c-9042-96be72aa4efd
watchDurationMillis = 15261
retainedDurationMillis = 254
mApplication instance of com.xintu.baomi.base.AppApplication
mBase instance of androidx.appcompat.view.ContextThemeWrapper
====================================
0 LIBRARY LEAKS
2021-06-16 14:56:19.738 26866-3293/? D/LeakCanary:
HEAP ANALYSIS RESULT
1 APPLICATION LEAKS
References underlined with "~~~" are likely causes. Learn more at https://squ.re/leaks. 11588 bytes retained by leaking objects Signature: e1c76f0955a7d673de751fa83bd6a78af3abee8 ┬─── │ GC Root: System class │ ├─ android.app.ActivityThread class │ Leaking: NO (a class is never leaking) │ ↓ static ActivityThread.sCurrentActivityThread │ ~~~~~~~~~~~~~~~~~~~~~~ ├─ android.app.ActivityThread instance │ Leaking: UNKNOWN │ Retaining 695.2 kB in 5281 objects │ mInitialApplication instance of com.xintu.baomi.base.AppApplication │ mSystemContext instance of android.app.ContextImpl │ mSystemUiContext instance of android.app.ContextImpl │ ↓ ActivityThread.mNewActivities │ ~~~~~~~~~~~~~~ ├─ android.app.ActivityThread$ActivityClientRecord instance │ Leaking: UNKNOWN │ Retaining 673.6 kB in 4855 objects │ activity instance of com.xintu.baomi.app.login.MainActivity with mDestroyed = false │ ↓ ActivityThread$ActivityClientRecord.nextIdle │ ~~~~~~~~ ├─ android.app.ActivityThread$ActivityClientRecord instance │ Leaking: UNKNOWN │ Retaining 672.7 kB in 4837 objects │ activity instance of com.xintu.baomi.app.show.ui.activity.LivePreparationActivity with mDestroyed = true │ ↓ ActivityThread$ActivityClientRecord.activity │ ~~~~~~~~ ╰→ com.xx.show.ui.activity.LivePreparationActivity instance Leaking: YES (ObjectWatcher was watching this because com.xx.show.ui.activity. LivePreparationActivity received Activity#onDestroy() callback and Activity#mDestroyed is true) Retaining 11.6 kB in 376 objects key = 7299ba45-b0b0-429c-9042-96be72aa4efd watchDurationMillis = 15261 retainedDurationMillis = 254 mApplication instance of com.xintu.baomi.base.AppApplication mBase instance of androidx.appcompat.view.ContextThemeWrapper ==================================== 0 LIBRARY LEAKS
这个堆栈我也没看出来具体是哪一块引起的,项目也是基于 你的框架 来改的😅
@tzrgaga 小伙子,从你提供的堆栈中我找不到任何有关 TitleBar 内存泄漏的代码,这样吧,这个 issue 我先关闭了,等你找到有这块的信息再反馈给我吧。
感觉像是这个静态变量导致的 Titlebar.sGlobalStyle