首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >金丝雀FirestoreRecyclerAdapter内存泄漏

金丝雀FirestoreRecyclerAdapter内存泄漏
EN

Stack Overflow用户
提问于 2020-03-02 07:08:36
回答 1查看 262关注 0票数 0

我得到了这个泄漏金丝雀记忆泄漏,这似乎是从回收视图

代码语言:javascript
复制
D/LeakCanary: ====================================
HEAP ANALYSIS RESULT
====================================
0 APPLICATION LEAKS

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

Library Leaks are leaks coming from the Android Framework or Google libraries.

Leak pattern: instance field android.view.ViewGroup$ViewLocationHolder#mRoot
Description: In Android P, ViewLocationHolder has an mRoot field that is not cleared in its clear() method. Introduced in https://github.com/aosp-mirror/platform_frameworks_base/commit/86b326012813f09d8f1de7d6d26c986a909d Bug report: https://issuetracker.google.com/issues/112792715
40271 bytes retained by leaking objects
Signature: 64becd25d6156daa91df6572a75b6a28ddb1
┬───
│ GC Root: System class
│
├─ android.view.ViewGroup$ViewLocationHolder class
│    Leaking: NO (a class is never leaking)
│    ↓ static ViewGroup$ViewLocationHolder.sPool
│                                          ~~~~~
├─ android.util.Pools$SynchronizedPool instance
│    Leaking: UNKNOWN
│    ↓ Pools$SynchronizedPool.mPool
│                             ~~~~~
├─ java.lang.Object[] array
│    Leaking: UNKNOWN
│    ↓ Object[].[0]
│               ~~~
├─ android.view.ViewGroup$ViewLocationHolder instance
│    Leaking: UNKNOWN
│    ↓ ViewGroup$ViewLocationHolder.mRoot
│                                   ~~~~~
├─ androidx.recyclerview.widget.RecyclerView instance
│    Leaking: YES (View.mContext references a destroyed activity)
│    mContext instance of com.android.rangroceryshopping.collaborate.CollaborateActivity with mDestroyed = true
│    View#mParent is set
│    View#mAttachInfo is null (view detached)
│    View.mID = R.id.collaborate_rv
│    View.mWindowAttachCount = 1
│    ↓ RecyclerView.mContext
╰→ com.android.rangroceryshopping.collaborate.CollaborateActivity instance
​     Leaking: YES (ObjectWatcher was watching this because com.android.rangroceryshopping.collaborate.CollaborateActivity received Activity#onDestroy() callback and Activity#mDestroyed is true)
​     key = d9d8e345-f645-4b3c-9f3e-5d5b7fd2cb4b
​     watchDurationMillis = 306199
​     retainedDurationMillis = 301199

====================================
METADATA

Please include this in bug reports and Stack Overflow questions.

Build.VERSION.SDK_INT: 28
Build.MANUFACTURER: samsung
LeakCanary version: 2.2
App process name: com.android.rangroceryshopping
Analysis duration: 18611 ms
Heap dump file path: /data/user/0/com.android.rangroceryshopping/files/leakcanary/2020-03-02_08-45-57_485.hprof
Heap dump timestamp: 1583131584691
====================================

我去掉了适配器,它只包含与FirestoreRecyclerAdapter扩展相关的变量。没有静态值,没有上下文,没有侦听器。我在另一个活动中有一个类似的适配器,没有任何问题。

我还试图将回收商的适配器设置为null,甚至在onStop中设置为null。还是帮不上忙。

代码语言:javascript
复制
@Override
protected void onStop() {
    super.onStop();
    if (mAdapter != null) {
        mRecyclerView.setLayoutManager( null );
        mRecyclerView.setAdapter( null );
        mAdapter.stopListening();
    }
}

这不可能是android的漏洞,因为其他活动也在使用这个漏洞,对吗?

在泄露信息时,我看到了这个链接,但我不确定我是否理解它。

泄漏金丝雀信息链接

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-03-12 23:39:58

答案在于您所粘贴的跟踪的描述:)

描述:在Android中,ViewLocationHolder有一个在其clear()方法中未被清除的mRoot字段。在base/commit/86b326012813f09d8f1de7d6d26c986a909d Bug报告中介绍:https://issuetracker.google.com/issues/112792715

这是一个已知的Android bug。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60484054

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档