Before I posted about
enums I talked to a number of folks, but I did not get the full story. Prompted by Jeroen Frijters comment I went back and checked
again…. Here is the quote from the Devlead for the JIT\Ngen:
We do in fact load enum
types at JIT time (after all at JIT time we do need to determine if it is an
enum and fetch their values). Also when enums are used as
parameters to functions we don’t know that they are enums (they look like value
classes in the signatures) unless we look them up (and we load them to determine
Thus in the jitted case
the enum will be loaded. If the module is NGENed, it will also be
loaded but at NGEN time (and then persist the loaded class in the NGEN image).
During execution we will never look at that class, so it does not cost us any
working set memory (or time).
I think it is fair to
say, however that people SHOULD be using Enums. Any performance
problem associated with them are solvable.
So, I was basically right in the
Ngen case and wrong in the JIT case, but I think my overall point still