我有以下的类:
public class MyClass
{
public string Name { get; set; }
public int Age { get; set; }
public double Amount { get; set; }
}
当我在64位系统上使用WinDbg尝试查找此类的大小时,我得到了大小为40,这一点让我无法理解,因为据我所读,MyClass应该有
8 bytes for SyncBlock
8 bytes for TypeHandle
8 bytes for string reference
4 bytes for Int32
8 bytes for double
= 36 bytes
我没有10个声望,所以无法发布图片。 有人知道为什么WinDbg显示了额外的4个字节吗?
string Name
也会占用内存。 - CodeZombie