Get class size of object

bearophile bearophileHUGS at lycos.com
Sun Aug 11 09:16:25 PDT 2013


Maxim Fomin:

> GC.sizeOf seems to return size of allocated page which is 
> bigger than needed (for ex. it returns 16 for a new int which 
> is 4).

The object instance contains a pointer to the virtual table, so 
there's a way to know what object it is. With that runtime 
information it should be possible to know the static size of the 
instance.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list