Umar Ata
04/09/2021, 6:35 PMoverride fun onDestroyView() {
super.onDestroyView()
_binding = null
}
Does the garbage collection type thing not works with viewbindig ?
Or I am on wrong track
Please adviseCasey Brooks
04/09/2021, 6:53 PMonDestroyView()
. Clearing out the binding helps ensure nothing is able to even try to modify the UI beyond this point, thus avoiding that whole class of issues. By not clearing the binding, there’s a potential for memory leaks or crashes in your app that are difficult to reproduce/debugmkrussel
04/09/2021, 8:36 PMonDestroyView
is to reduce memory usage by cleaning up all the views. If you keep a reference to the view binding, then the memory will not get cleaned up.
At one of the Google IO events, they mentioned changing this behavior to destroy the fragment at the same time as the view because it was a common source of bugs. I don't know if they ever made that change.FunkyMuse
04/09/2021, 9:12 PMIan Lake
04/10/2021, 3:28 AMJoost Klitsie
04/10/2021, 9:24 AM