I'm using Kotlin for Android development. Interesting question. In Java saving Context in static field is a memory leak. But if I'm storing context in Kotlin companion object, Android Studio doesn't say that it's a memory leak. It's means that in Java bytecode conpanion object is not a static code? For example:
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
appContext = applicationContext
}
companion object {
lateinit var appContext: Context
}
}
Here is no memory leak? Thanks for answers :)