ObjectLayoutInspector icon indicating copy to clipboard operation
ObjectLayoutInspector copied to clipboard

Probably wrong layout for System.Object

Open controlflow opened this issue 1 year ago • 1 comments

ObjectLayoutInspector.TypeLayout.PrintLayout<object>();

Prints:

Type layout for 'Object'
Size: 8 bytes. Paddings: 0 bytes (%0 of empty space)
|============================|
| Object Header (8 bytes)    |
|----------------------------|
| Method Table Ptr (8 bytes) |
|============================|
|============================|

However, empty classes occupy IntPtr.Size bytes (ObjectLayoutInspector.TypeInspector.GetSizeOfReferenceTypeInstance(typeof(object)) returns 8 on 64-bit OS).

controlflow avatar Nov 17 '24 18:11 controlflow

AFAIK it does not count the header and method table ptr. And you get the 8 from the addiitional invisible padding.

To count all use FullSize.

Technus avatar Feb 17 '25 22:02 Technus