TheDukerChip
06/11/2019, 7:06 AMenums
are restricted to use because it takes a bit large memory
Instead of enum
android suggested to use the TypeDef
according to the above video.
Can we use the `enum`'s in kotlin or we should go with the any alternatives?louis993546
06/11/2019, 7:20 AMchris.chen
06/11/2019, 7:21 AMlouis993546
06/11/2019, 7:21 AMMatej Drobnič
06/11/2019, 7:22 AMlouis993546
06/11/2019, 7:23 AMzokipirlo
06/11/2019, 7:50 AMTheDukerChip
06/11/2019, 9:15 AMgildor
06/11/2019, 9:44 AMthe cost of enum a lot lessenum cost is exactly the same: 1 empty object per enum value, 1 class per enum type
it is from the days when Android device’s memory management suckedNothing changed from those days in terms of enum cost, it’s just allocation of an object per enum value and even on Dalvik and first devices with 128-256mb of RAM it never was a real problem
ART changed things a lotART has nothing to do with enums, ART improved GC a lot, but because enums never garbage collected, so GC improvement is not really related to enums Object allocation is also faster on ART, so it somehow related to enums on first access, but this time is so small comparing to thousands and thousands of other objects created on app start and even more during app work that it’s just impossible to measure So this advice was outdated in 2015 and even in 2010 pretty questionable trade-off to lose type safety to save a few kilobytes
ghedeon
06/11/2019, 10:42 AMMatej Drobnič
06/11/2019, 12:21 PM2556 bytes
. I don't think even Hello World example is that small, with support library 😄jw
06/11/2019, 11:46 PMTheDukerChip
06/12/2019, 8:46 AMenum
doesn't affects the memory or performance, ryt?gildor
06/12/2019, 8:55 AMjw
06/12/2019, 1:57 PM