How are enums handled when it comes to the heap, memory, and when an enum type instance is created? If I've got an enum with fifty field constants, then do I have fifty objects on the heap representing that enum type (when accessed), and are there performance concerns?
views:
31answers:
1
+2
A:
The first time the type is accessed and it gets initialized, a new object is created for each value. However, unless you have a huge number of instance fields in the enum, each object will be very small. I'd be very surprised to see a situation in which this was a real performance concern unless you were on a massively constrained device.
Jon Skeet
2010-02-22 19:57:36