https://kotlinlang.org logo
Title
c

carlos cdmp

05/02/2019, 11:12 AM
I usually use Objects to isolate functionality, like
object TextUtils
for instance, instead of just top level functions, as it is creating an instance, it should be using more memory than an old java static function. Do someone know if an object with only functions its a waste of memory when the functions could be top-level?
d

diesieben07

05/02/2019, 11:13 AM
Technically it does "waste" memory. On a modern 64-Bit VM a plain object takes 16 bytes. If that is an issue for your application, I guess you can optimize it. But I don't think it's worth it.
r

ribesg

05/02/2019, 11:17 AM
If you really have memory problems, optimizing function-holding singletons into top level functions will clearly not be your first step
2