VS memory profiler tells me that when I add a byte field to my class, it does not take any additional memory right at the start of application, but if it’s an int or object, it takes additional 4 bytes per instance.
Are there any other types, or can I create my own that don’t take up memory before assigned a value?
Also will the memory free up when the value becomes null (zero) again?
Memory on a 32-bit platform is typically allocated in allocation units of 4 bytes. I assume the .NET Runtime is doing just that.
The C# compiler uses a layout that results in the smallest allocation size for a class/struct (unless you use annotations to indicate otherwise, which one would do e.g. when using interop to communicate with unmanaged code that lays out memory differently). That means that