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

Memory leak #64

Closed
alexeyr15 opened this issue Jan 11, 2015 · 4 comments
Closed

Memory leak #64

alexeyr15 opened this issue Jan 11, 2015 · 4 comments
Labels

Comments

@alexeyr15
Copy link

I use a snackbar with the custom duration 10 sec. If a user presses Back when a snackbar is showing, then the activity is finished but it cannot be garbage collected because there is a strong reference to it from the handler queue (due to postDelayed() method call):

Handler -> mDismissRunnable -> Snackbar (outer class) -> Activity

I think it is needed to call removeCallbacks(mDismissRunnable); from onDetachedFromWindow(), for example.

@wmora
Copy link
Contributor

wmora commented Jan 11, 2015

Thanks for reporting this. As a workaround, could you dismiss all Snackbars on your onPause() method?

@wmora wmora added the bug label Jan 11, 2015
@alexeyr15
Copy link
Author

I don't think that dismissing a snackbar eliminates the memory leak. As I see from the source code removeCallbacks(mDismissRunnable) is only called when swiping a snackbar. So if I would call dismiss() in onPause() a reference to the activity is still exists and will be only destroyed when Runnable in postDelayed() is fired.

@wmora
Copy link
Contributor

wmora commented Jan 11, 2015

I see. Will upload a version shortly with the call in onDetachedFromWindow() as you suggested. It's probably the best place to remove the callbacks

@wmora wmora closed this as completed in 04ed7df Jan 11, 2015
@wmora
Copy link
Contributor

wmora commented Jan 12, 2015

Released in 2.7.4

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

No branches or pull requests

2 participants