三星[4.4,5.0]使用EditText导致内存泄露

本文介绍了在三星4.4至5.0系统中,由于ClipboardUIManager.java导致的EditText内存泄露问题。问题源自ClipboardUIManager的单例持有Activity的Context,而非Application的Context。解决方案是确保在页面启动时,如onCreate或onResume,使用Application的Context初始化ClipboardUIManager。
摘要由CSDN通过智能技术生成

1. 问题描述

  今天线上监控发现一个页面泄露的问题,GC ROOT如下:

* GC ROOT android.os.HandlerThread.mLooper
* references android.os.Looper.sMainLooper
* references android.os.Looper.mQueue
* references android.os.MessageQueue.mMessages
* references android.os.Message.sPool
* references android.os.Message.target
* references android.widget.Editor$Blink.this$0
* references android.widget.Editor.mTextView
* references android.widget.EditText.mClipboardExManager
* references android.sec.clipboard.ClipboardExManager.mClipboardUIManager
* references android.sec.clipboard.ClipboardUIManager.mContext
* leaks xxxxxxx.activity.XxxxInputActivity instance

  看包名都是系统的类,但是找了下系统源码,在4.0.4, 4.4.4, 5.1.1, 6.0.1里都没有出现过ClipboardUIManager.java这个类,所以应该是产商定制的类。到google里搜一下android.sec.clipboard.ClipboardUIManager.mContext,有不少相同的问题,都是出现在三星手机上的,具体问题讨论过程看这里

  对了一下出问题的手机型号和系统:SM-N9008S、SM-N9008、SM-A7000、SM-G9008V、SM-N9006,使用的官方ROM的确都是4.4.2、5.0版本,下面详细分析这个问题。

2. 问题分析:

  其实这种类型的堆栈是比较常见的,第一眼看上去就是Looper的队列里有未被消费的消息,这个消息持有了一个内部类对象(类似Editor$Blick.this$

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值