ObjectLayoutInspector icon indicating copy to clipboard operation
ObjectLayoutInspector copied to clipboard

Size doesn't include Object Header and Method Table Ptr

Open DmitryMak opened this issue 1 year ago • 1 comments

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)               |
|========================================|

DmitryMak avatar May 06 '24 21:05 DmitryMak

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.

Technus avatar Feb 17 '25 22:02 Technus