Here’s the situation:
- I’m using Navigation component, Airbnb Epoxy, TwoPaneSlidnig, Databinding and MVVM architecture
- I have one Activity, few Fragments, two Navhost (one for detail-pane and the main one)
Problem: When I navigate to the other navhost, leakCanary give me a memory leak.
Memory-Leak (when I navigate from detail-pane navhost to main navhost):
Leaking: YES (ObjectWatcher was watching this because com.example..
received Fragment#onDestroyView() callback (references to its views
should be cleared to prevent leaks))
Memory-Leak (when I navigate from main navhost to detail-pane navhost):
Something about mFragmentManager = null in the Fragment#onDestroyView()
Actually I checked my two-pane-fragment where I use epoxy, I checked it line by line and I realized when I delete the commands inside of the click-listener, leak-memory is gone!!! My click-listener is something like this:
tasks.forEach { currentTask ->
task {
id(currentTask.id)
task(currentTask)
clickListener { v ->
// I’m talking about here
}
}
}
End of the analysis report, leakCanary asked me to report this bug:
Please include this in bug reports and Stack Overflow questions.
Build.VERSION.SDK_INT: 22
Build.MANUFACTURER: Samsung
LeakCanary version: 2.10
Class count: 6703
Instance count: 277957
Primitive array count: 32099
Object array count: 37297
Thread count: 24
Heap total bytes: 46827179
Bitmap count: 459
Bitmap total bytes: 0
Large bitmap count: 3
Large bitmap total bytes: 0
Db 1: open /data/data/.../databases/my_database
Stats: LruCache[maxSize=3000,hits=24402,misses=130492,hitRate=15%]
RandomAccess[bytes=10207608,reads=130492,travel=46962620544,range=26848575,size=51549182]
Analysis duration: 166862 ms