android-auto-scroll-view-pager icon indicating copy to clipboard operation
android-auto-scroll-view-pager copied to clipboard

AutoScrollViewPager.mContext leaks DemoActivity instance (48 KB)

Open logan676 opened this issue 8 years ago • 4 comments

logs

net.tsz.afinal.core.AsyncTask.sHandler * references net.tsz.afinal.core.AsyncTask$InternalHandler.mQueue * references android.os.MessageQueue.mMessages * references android.os.Message.next * references android.os.Message.target * references cn.trinea.android.view.autoscrollviewpager.AutoScrollViewPager$MyHandler.this$0 * references cn.trinea.android.view.autoscrollviewpager.AutoScrollViewPager.mContext * leaks cn.com.demo.DemoActivity instance * Retaining: 48 KB. * Reference Key: 2cd1903-be4e-4d3e-8f94-efa50c058ec7 * Device: Xiaomi Xiaomi MI NOTE Pro leo * Android Version: 5.1.1 API: 22 LeakCanary: 1.5 00f37f5 * Durations: watch=15287ms, gc=231ms, heap dump=3338ms, analysis=54623ms 

logan676 avatar Jan 20 '17 03:01 logan676

I meet the same problem,this is a serious bug!

gavin0x00 avatar Feb 19 '17 05:02 gavin0x00

the patch below should fix the leak


+    @Override
+    protected void onDetachedFromWindow() {
+        super.onDetachedFromWindow();
+        if (handler != null) {
+            handler.removeCallbacksAndMessages(null);
+        }
+    }
+

logan676 avatar Mar 09 '17 02:03 logan676

@Logan676 where to write this piece of code? I am using this library in a fragment , onDetachedFromWindow() is not available in Fragment. Which function to override for my scenario

rajatgupta1993 avatar May 31 '17 19:05 rajatgupta1993

maybe you can still place the patch in activity, what`s the matter is how to make fragment talk with activity, there are several ways to do that.

logan676 avatar Jun 01 '17 02:06 logan676