最近发现项目中,一个地方总是报内存泄漏,LeakCanary给出的信息如下图所示:

既然泄漏了,那么肯定得找泄漏的地方啊,android studio profiler 和 mat轮番上阵,但是就是找不到泄漏点,很奇怪。。。最后在github的LeakCanary 问题那发现了这个:
LeakCanary-Issues
GC ROOT static android.view.inputmethod.InputMethodManager.sInstance
references android.view.inputmethod.InputMethodManager.mLastSrvView
references com.xx.TextView.mContext
leaks com.xxx.activity.XXXActivity instance
LeakCanary 对于这个问题的回复:
Thank you for your report, it looks like this might be a leak in the Android SDK.
Please read the following entry in our FAQ: [Can a leak be caused by the Android SDK?](https://github.com/square/leakcanary/wiki/FAQ#can-a-leak-be-caused-by-the-android-sdk).
We don't have enough time to do the investigative work on this type of issue, so I will close this issue for now. We'll happily take contributions to `AndroidExcludedRefs.java`, if the leak is demonstrated and the fix provided to AOSP.
大概意思就是这可能是一个android sdk中的内存泄漏。。。。没精力管这种
然后我搜索了一下关于InputMethodManager的内存泄漏,发现很多这种问题,在15<=API<=23中都存在,特此记录一下,如果以后发现不是sdk问题而是代码问题的话,会纠正此贴~
网友评论