databinding内存泄露

发布于 2022-09-11 22:45:40 字数 2701 浏览 50 评论 0

ApplicationLeak(className=android.widget.LinearLayout, leakTrace=
┬
├─ android.app.ActivityThread
│    Leaking: NO (ActivityThread↓ is not leaking and a class is never leaking)
│    GC Root: System class
│    ↓ static ActivityThread.sCurrentActivityThread
├─ android.app.ActivityThread
│    Leaking: NO (ArrayMap↓ is not leaking)
│    ↓ ActivityThread.mActivities
├─ android.util.ArrayMap
│    Leaking: NO (Object[]↓ is not leaking)
│    ↓ ArrayMap.mArray
├─ java.lang.Object[]
│    Leaking: NO (ActivityThread$ActivityClientRecord↓ is not leaking)
│    ↓ array Object[].[1]
├─ android.app.ActivityThread$ActivityClientRecord
│    Leaking: NO (MainActivity↓ is not leaking)
│    ↓ ActivityThread$ActivityClientRecord.activity
├─ com.ukex.module.index.ui.MainActivity
│    Leaking: NO (FragmentController↓ is not leaking and Activity#mDestroyed is false)
│    ↓ MainActivity.mFragments
├─ androidx.fragment.app.FragmentController
│    Leaking: NO (FragmentActivity$HostCallbacks↓ is not leaking)
│    ↓ FragmentController.mHost
├─ androidx.fragment.app.FragmentActivity$HostCallbacks
│    Leaking: NO (FragmentManagerImpl↓ is not leaking)
│    ↓ FragmentActivity$HostCallbacks.mFragmentManager
├─ androidx.fragment.app.FragmentManagerImpl
│    Leaking: NO (NavHostFragment↓ is not leaking)
│    ↓ FragmentManagerImpl.mPrimaryNav
├─ androidx.navigation.fragment.NavHostFragment
│    Leaking: NO (FragmentManagerImpl↓ is not leaking and Fragment#mFragmentManager is not null)
│    ↓ NavHostFragment.mChildFragmentManager
├─ androidx.fragment.app.FragmentManagerImpl
│    Leaking: NO (HashMap↓ is not leaking)
│    ↓ FragmentManagerImpl.mActive
├─ java.util.HashMap
│    Leaking: NO (HashMap$Node[]↓ is not leaking)
│    ↓ HashMap.table
├─ java.util.HashMap$Node[]
│    Leaking: NO (HashMap$Node↓ is not leaking)
│    ↓ array HashMap$Node[].[0]
├─ java.util.HashMap$Node
│    Leaking: NO (HomeFragment↓ is not leaking)
│    ↓ HashMap$Node.value
├─ com.ukex.module.index.ui.HomeFragment
│    Leaking: NO (Fragment#mFragmentManager is not null)
│    ↓ HomeFragment.dataBinding
│                   ~~~~~~~~~~~
├─ com.ukex.databinding.HomeFragmentBindingImpl
│    Leaking: UNKNOWN
│    ↓ HomeFragmentBindingImpl.mRoot
│                              ~~~~~
╰→ android.widget.LinearLayout
​     Leaking: YES (ObjectWatcher was watching this)
​     mContext instance of com.ukex.module.index.ui.MainActivity with mDestroyed = false
​     View#mParent is null
​     View#mAttachInfo is null (view detached)
​     View.mWindowAttachCount = 1
​     key = b7ad80c9-203d-416e-ba52-8d8b2edca920
​     watchDurationMillis = 17179
​     retainedDurationMillis = 12178
, retainedHeapByteSize=6367)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

╰◇生如夏花灿烂 2022-09-18 22:45:40

在onDestroyView 添加

override fun onDestroyView() {
    super.onDestroyView()
    binding?.unbind()
    binding = null
}

binding 对象中有View的 引用..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文