Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Memory leak in MaterialViewPagerHelper #15

Closed
MGaetan89 opened this issue May 9, 2015 · 6 comments
Closed

Memory leak in MaterialViewPagerHelper #15

MGaetan89 opened this issue May 9, 2015 · 6 comments
Assignees

Comments

@MGaetan89
Copy link

I started using https://github.com/square/leakcanary to find potential memory leaks in my application.

Turns out there is one in your great library in MaterialViewPagerHelper. Indeed, it holds a static HashMap that is never cleared. Maybe you could add a method to clear the content of that map when the Activity/Fragment is destroyed?

@florent37
Copy link
Owner

Yes, I thinks it would be usefull.

Do you want to do in and send a pull request ?

if not I will do it myself, just to prevent doing same work twice

@MGaetan89
Copy link
Author

I can't work on this for the next two weeks.
I can have a look then if you haven't fixed it yet.

@florent37
Copy link
Owner

I fixed it in 1.0.3.1 can you check please ? :)

@florent37
Copy link
Owner

MaterialViewPager.java

@Override
protected void onDetachedFromWindow() {
    MaterialViewPagerHelper.unregister(getContext());
    super.onDetachedFromWindow();
}

MaterialViewPagerHelper.java

public static void unregister(Context context) {
    if(context != null)
        hashMap.remove(context);
}

@MGaetan89
Copy link
Author

It looks like there is no issue now.
Thanks for the quick fix 😄

@florent37
Copy link
Owner

Thanks for your reporting 👍

@florent37 florent37 self-assigned this May 10, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants