【问题标题】:leaked nestedscrollView using fragment and navigation component使用片段和导航组件泄漏的nestedscrollView
【发布时间】:2020-09-01 14:34:56
【问题描述】:

我从 leack canary 获得了这个泄露的转储,但不知何故我不明白如何解决这个问题。

┬───
│ 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 的导航组件 里面有很多表单处理

任何想法都非常感谢,谢谢!

【问题讨论】:

  • 当 Activity 被销毁时,我与 androidx.core.widget.NestedScrollView 有类似的泄漏,但我什至没有在任何地方引用 NestedScrollView,而是在我的布局中。嗯...

标签: android android-jetpack leakcanary


【解决方案1】:

这个问题似乎很老,但我不时遇到这个问题,所以这是我目前所知道的:

  • 除了使用反射之外,我还没有找到任何解决方案。
  • LeakCanary 2.6 已将此标记为库泄漏(当然,由于 OutOfMemory 异常,它仍然可能导致您的应用程序崩溃)。

【讨论】:

    猜你喜欢
    • 2020-11-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-28
    • 1970-01-01
    • 1970-01-01
    • 2012-03-05
    • 1970-01-01
    相关资源
    最近更新 更多