Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoScrollViewPager.mContext leaks DemoActivity instance (48 KB) #33

Open
Logan676 opened this issue Jan 20, 2017 · 4 comments
Open

AutoScrollViewPager.mContext leaks DemoActivity instance (48 KB) #33

Logan676 opened this issue Jan 20, 2017 · 4 comments

Comments

@Logan676
Copy link

Logan676 commented Jan 20, 2017

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 

@gavin0x00
Copy link

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

@Logan676
Copy link
Author

Logan676 commented Mar 9, 2017

the patch below should fix the leak


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

@rajatgupta1993
Copy link

@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

@Logan676
Copy link
Author

Logan676 commented Jun 1, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants