Object Memory Space
-
Does anyone know what factors affect the memory size an object will consume by simply creating a new instance? I know that member-level value-types will consume memory respective of their data type (Int32 consumes 4 bytes, etc.). What about code? Does a class that contains no member variables, but 2000 lines of code consume any memory by simply instantiating a new one?
-
Does anyone know what factors affect the memory size an object will consume by simply creating a new instance? I know that member-level value-types will consume memory respective of their data type (Int32 consumes 4 bytes, etc.). What about code? Does a class that contains no member variables, but 2000 lines of code consume any memory by simply instantiating a new one?
CBoland wrote: Does anyone know what factors affect the memory size an object will consume by simply creating a new instance? I know that member-level value-types will consume memory respective of their data type (Int32 consumes 4 bytes, etc.). What about code? Does a class that contains no member variables, but 2000 lines of code consume any memory by simply instantiating a new one? Generally, no. Since .NET is garbage collected, an instance of a class needs some information for garbage collection and Reflection. IIRC, any Object instance on .NET takes 16 bytes of memory. Another common source of "hidden" memory consumption on OOP environments are virtual methods. ORACLE One Real A$#h%le Called Lary Ellison
-
Does anyone know what factors affect the memory size an object will consume by simply creating a new instance? I know that member-level value-types will consume memory respective of their data type (Int32 consumes 4 bytes, etc.). What about code? Does a class that contains no member variables, but 2000 lines of code consume any memory by simply instantiating a new one?
Code shouldnt affect memory.. but if you have declared any virtual functions or derived from some some asbtract base class.. it will as vtable does require some space.. And any static variables also consume.. but only once.. aravinthan
Visit me:
http://www2.domaindlx.com/earavi/
When you know something.. its meant to share with others :-) for otherwise that knowledge has no worth:-)
mail me:
aravinthan@rediffmail.com