问题描述
我有一个从leack canary泄漏的垃圾堆,但不知如何解决。
@H_404_2@┬───
│ GC Root: System class
│
├─ android.view.inputmethod.InputMethodManager class
│ Leaking: NO (InputMethodManager↓ is not leaking and a class is never leaking)
│ ↓ static InputMethodManager.sInstance
├─ android.view.inputmethod.InputMethodManager instance
│ Leaking: NO (InputMethodManager is a singleton)
│ ↓ InputMethodManager.mCurrentInputConnection
│ ~~~~~~~~~~~~~~~~~~~~~~~
├─ com.android.internal.widget.EditableInputConnection instance
│ Leaking: UNKNowN
│ ↓ EditableInputConnection.mTargetView
│ ~~~~~~~~~~~
├─ androidx.appcompat.widget.AppCompatEditText instance
│ Leaking: YES (View detached and has parent)
│ mContext instance of .android.SIActivity with mDestroyed = false
│ View#mParent is set
│ View#mAttachInfo is null (view detached)
│ View.mID = R.id.name
│ View.mWindowAttachCount = 1
│ ↓ AppCompatEditText.mParent
├─ androidx.constraintlayout.widget.ConstraintLayout instance
│ Leaking: YES (AppCompatEditText↑ is leaking and View detached and has parent)
│ mContext instance of .android.SIActivity with mDestroyed = false
│ View#mParent is set
│ View#mAttachInfo is null (view detached)
│ View.mID = R.id.containerName
│ View.mWindowAttachCount = 1
│ ↓ ConstraintLayout.mParent
├─ androidx.constraintlayout.widget.ConstraintLayout instance
│ Leaking: YES (ConstraintLayout↑ is leaking and View detached and has parent)
│ mContext instance of .android.SIActivity with mDestroyed = false
│ View#mParent is set
│ View#mAttachInfo is null (view detached)
│ View.mWindowAttachCount = 1
│ ↓ ConstraintLayout.mParent
╰→ androidx.core.widget.nestedScrollView instance
Leaking: YES (ObjectWatcher was watching this because .android.si.SILeadInfoFragment received Fragment#onDestroyView() callback (references to its views should be cleared to prevent leaks))
key = a7452263-5234-4656-9425-754c455f1b06
watchDurationMillis = 11855
retainedDurationMillis = 6853
mContext instance of .android.SIActivity with mDestroyed = false
View#mParent is null
View#mAttachInfo is null (view detached)
View.mWindowAttachCount = 1
应用程序的某些背景: 它正在使用jetpack的导航组件 里面有很多表格处理
任何想法,谢谢!
解决方法
这个问题似乎很老,但我不时遇到这个问题,所以这是我目前所知道的:
- 除了使用反射之外,我还没有找到任何解决方案。
- LeakCanary 2.6 已将此标记为库泄漏(当然,由于 OutOfMemory 异常,它仍然是可能导致应用崩溃的泄漏)。