class Book
{
public int ISBN { get; set; }
}
void Method()
{
Book book = new Book();
// Break and verify in SoS Debugging.
}
!dumpheap -type Book
PDB symbol for clr.dll not loaded
Address MT **Size**
00c6b76c 009b7f2c **12**
total 0 objects
Statistics:
MT Count TotalSize Class Name
009b7f2c 1 12 GCTest.Book
Total 1 objects
How the size of object here is 12 bytes . It contains only one integer property. sizeof(int) = 4 bytes remaining 8 bytes ? (object instantiation). Can anyone shed some light.
Every reference object has two extra field appended :
Object type ptr
: 4 bytes (ddress of a memory (AppDomain specific) that contains a structure holding the Method Table of the Reference Type for which the object is instantiated or points to)
Sync block adress
: 4 bytes (sync block address and points to a location in a process-wide table that contains structures used for synchronizing access to instances of Reference Types)
More info Check the memory layout in this article