Object layout structure in .NET using a disassembler

I am interested in seeing the layout structure of an object and am trying to use disassembly in visual studio. Below 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 the Memory1 window and typed myc into the Address field. I get the following data in the output window (using 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 seems that there is an additional pointer 00a7931c, which is added before the object data, which increases the size of the object by 4 bytes. My confusion is that the documentation says that the size of an object is increased by 8 bytes due to the header on the object. Can someone tell me where the remaining 4 bytes are?

+3
source share
2 answers

.Net- - CLR:

CLR :

[DWORD: SyncBlock] [DWORD: MethodTable Pointer] [DWORD: ]... [ ]...

: [DWORD: SyncBlock]
: [DWORD: MethodTable Pointer] [DWORD: ]... [ ]...

ObjHeader ( ). ObjHeader SyncBlock.

+6

0x0148B7B8. :

SyncBlock ( ptr) Table ( ptr) ...

, ( ).

+1

All Articles