'Storing constants in Fragment's companion object - a memory leak?
My understanding of companion object in Kotlin is that they are analogous to static
modifiers in Java.
It's bad practice to store static fields in Activities and Fragments as it can lead to memory leaks.
With that in mind, will this kind of code lead to memory leak?
class ChangePassFragment : Fragment(R.layout.fragment_change_password) {
companion object {
const val TIMER_SLEEP_TIME = 180
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|