Open anhanh11001 opened 5 years ago
Reopening because there might be other reasons for memory leaks. Please check @anhanh11001
@liveHarshit can you also take a look at this issue as well, I'm not sure for now
@liveHarshit can you also take a look at this issue as well, I'm not sure for now
Sure :+1: This issue needs to divide into different parts. There are multiple memory leaks. We can list them manually and solve them.
@anhanh11001 @iamareebjamal What if we use data bindings for fragments instead of using lateinit rootView
, I think it is causing for memory leaks.
It's not. The listeners are causing the memory leak. If you use the binding. binding and hence, the root view will get leaked
Okay and leaking always starts with message Fragment#mFragmentManager is not null
in case of recycling adapters, I don't understand what it's mean?
Doesn't matter. It means that the fragment fragmentmanager is not null and thus leaked, leaking the fragment
DiffCallBack could also be the cause? I am not sure
Just remove the listeners in onDestroyView
or make it static?
Then change the title to "Add more memory leaks"
Just remove the listeners in onDestroyView
Click listeners are removed in #1766 But still, there are memory leaks with recycler adapters -
These clearly show swipe refresh listener not being removed
These clearly show swipe refresh listener not being removed
But it is set to null - https://github.com/fossasia/open-event-android/blob/91eda72bab0ed86f564ed26d259b7acb1eff7c7a/app/src/main/java/org/fossasia/openevent/general/event/EventsFragment.kt#L209
Will see what's happening
@liveHarshit I encountered a similar issue, rootview was leaking for me. Try removing the rootview, Im not sure about open-event's codebase but someone did code the fragments similar to EventsFragment.kt
@adityastic will try
Try removing the rootview
Not a solution
also set adapter to null https://stackoverflow.com/questions/35520946/leak-canary-recyclerview-leaking-madapter
Stack OverflowI decided it was high time I learned how to use Leak Canary to detect Leaks within my apps, and as I always do, I tried to implement it in my project to really understand how to use the tool.
also set adapter to null https://stackoverflow.com/questions/35520946/leak-canary-recyclerview-leaking-madapter
Stack OverflowLeak canary, Recyclerview leaking mAdapterI decided it was high time I learned how to use Leak Canary to detect Leaks within my apps, and as I always do, I tried to implement it in my project to really understand how to use the tool.
Tried, it worked. But Areeb said it is just a workaround, not a fix so it wasn't implemented. https://github.com/fossasia/open-event-attendee-android/pull/1766#issuecomment-492699626
Stack OverflowI decided it was high time I learned how to use Leak Canary to detect Leaks within my apps, and as I always do, I tried to implement it in my project to really understand how to use the tool.
@anhanh11001 It actually just prevents LeakCanary to report it as memory leak. It doesn't solve the memory leak
Describe the bug In most fragment, setting up RecyclerView and Adapter leads to memory leaks reported by Leak Canary
Screenshots
Additional context
1705 related issue
Would you like to work on the issue? Yes