https://kotlinlang.org logo
r

rb90

05/25/2021, 2:53 PM
Hi, one questions regarding classes which contains
companion object
. Are that classes fully garbage collected on android as well as on ios?
1
k

Kris Wong

05/25/2021, 3:52 PM
`companion object`s have application lifetime just like any other
object
r

rb90

05/25/2021, 3:56 PM
okay so that that objects were singletons inside classes which means that they have the same lifetime as singletons which means that they don't get garbage collected, right?
l

louiscad

05/25/2021, 4:36 PM
All objects and top level properties can never be garbage collected, that's the same in Swift, Java and many more. Doing differently would be highly suprising and could break code.
👍 5