使用反汇编器的.NET 中的对象布局结构
我有兴趣查看对象布局结构,并尝试在 Visual Studio 中使用反汇编。 以下是我的代码:
class myclass
{
public int m_a;
}
myclass myc = new myclass();
myc.m_a = 23;
//I am setting a breakpoint after this line
我打开 Memory1 窗口,然后在“地址”字段中键入 myc。我在输出窗口中得到以下详细信息(使用带有 Intel 编译器的 Windows XP PC 32 位):
0x0148B7BC 1c 93 a7 00 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00
似乎在对象数据前面添加了一个附加指针 00a7931c,这使对象大小增加了 4 个字节。我的困惑是文档说由于每个对象的标头,对象大小增加了 8 个字节。有人可以指出其他 4 个字节在哪里吗?
I am interested in seeing the object layout structure, and am trying to use a disassembly in visual studio.
Following is my code:
class myclass
{
public int m_a;
}
myclass myc = new myclass();
myc.m_a = 23;
//I am setting a breakpoint after this line
I opened Memory1 window, and type myc in the Address field. I get the following details int the output window (used Windows XP PC 32bit with Intel compiler):
0x0148B7BC 1c 93 a7 00 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00
It appears that there is an additional pointer 00a7931c which is added in front of the object data, which increases the object size by 4 bytes. My confusion is that documentation says that object size is increase by 8 bytes due to header per object. Can someone please point me to where the other 4 bytes are?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自 高级 .Net 调试 - CLR 对象的内部结构:
From Advanced .Net Debugging - CLR Object’s Internal Structure:
看一下 0x0148B7B8。对象结构是:
SyncBlock (ptr size)
方法表(ptr 大小)
字段...
引用指向方法表,以允许更快的取消引用(考虑虚拟方法和属性调用与锁定的相对频率)。
Take a look at 0x0148B7B8. An objects structure is:
SyncBlock (ptr size)
MethodTable (ptr size)
Fields...
The reference points to the method table, to allow for faster dereferencing (consider the relative frequency of virtual method and property calls vs. locking).