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$