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 in ViewGroupMviDelegateImpl #310

Open
qwert2603 opened this issue Apr 28, 2018 · 2 comments
Open

Memory leak in ViewGroupMviDelegateImpl #310

qwert2603 opened this issue Apr 28, 2018 · 2 comments
Labels

Comments

@qwert2603
Copy link
Contributor

qwert2603 commented Apr 28, 2018

Hello!
I found a memory leak in ViewGroupMviDelegateImpl.
Mosby version is 3.1.0.

Steps to reproduce:

  • create CustomView extending MviFrameLayout or MviLinearLayout or MviRelativeLayout
  • programmaticaly add this CustomView to view hierarchy while activity is resumed
  • programmaticaly remove this CustomView from view hierarchy while activity is resumed

After that CustomView will be in memory until activity is destroyed.
I also found that this is because of registering ActivityLifecycleCallbacks when creating ViewGroupMviDelegateImpl.
ViewGroupMviDelegateImpl removes ActivityLifecycleCallbacks only when activity is destroyed. But there may be a lot of such CustomView those will hang in memory though they are detached and removed from view hierarchy.

I reviewed logic of consuming activity-lifecycle in ViewGroupMviDelegateImpl and may be we can register ActivityLifecycleCallbacks when attaching view to presenter and unregister ActivityLifecycleCallbacks in two cases: when activity is destroying and also when detaching view from presenter ?

@sockeqwe
Copy link
Owner

sockeqwe commented Apr 28, 2018 via email

@dimsuz
Copy link

dimsuz commented Apr 28, 2018

+1 I have experienced this issue too, caught it with Leak Canary.

qwert2603 added a commit to qwert2603/andrlib that referenced this issue May 3, 2018
@sockeqwe sockeqwe added the bug label May 15, 2018
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

3 participants