ObjectLayoutInspector
ObjectLayoutInspector copied to clipboard
Size doesn't include Object Header and Method Table Ptr
In the following printed layout, Size seems off by 16B because it does not include Object Header and Method Table Ptr:
Size: 40. Paddings: 11 (%27 of empty space) <-- Shouldn't Size be 56B instead?
|========================================|
| Object Header (8 bytes) | <-- Not included in Size: 40
|----------------------------------------|
| Method Table Ptr (8 bytes) | <-- Not included in Size: 40
|========================================|
| 0: Byte b (1 byte) |
|----------------------------------------|
| 1-7: padding (7 bytes) |
|----------------------------------------|
| 8-19: NotAlignedStruct sp1 (12 bytes) |
| |================================| |
| | 0: Byte m_byte1 (1 byte) | |
| |--------------------------------| |
| | 1-3: padding (3 bytes) | |
| |--------------------------------| |
| | 4-7: Int32 m_int (4 bytes) | |
| |--------------------------------| |
| | 8: Byte m_byte2 (1 byte) | |
| |--------------------------------| |
| | 9: padding (1 byte) | |
| |--------------------------------| |
| | 10-11: Int16 m_short (2 bytes) | |
| |================================| |
|----------------------------------------|
| 20-23: padding (4 bytes) |
|========================================|
I guess this is a design choice to make the size behave similar for structs (while also printing the Header/Table Ptr for convience)
Use FullSize to have that included.