Just realized a very subtle potential source of he...
# android
k
Just realized a very subtle potential source of headache in my project with Kotlin's
lazy
and Android fragment. The fragment view might have been destroyed and recreated, but since we could still have the same fragment instance, a lazy initialized variable pointing to the view would be referencing an already disposed object. = buggy code + memory leak I'm referring to this kinda setup
val view by lazy { findViewById(R.id.view) }
Hopefully, this helps someone