sizeof(a)
Run
in you example is in no way related to the object size, but is the size of of
the reference itself. That is the size of the managed pointer, in C it would be
the size of a pointer. That value is 4 or 8 byte on 32 or 64 bit systems, and
it is unrelated to the size of the object which the ref points to.
Well, that is what Yardanico already told you :-)
More interesting is
type
A = ref object of RootObj
i: cint
B = ref object
i: cint
echo sizeof(A()[]) #16
echo sizeof(B()[]) #4
Run
I think B()[] is a plain C struct, while A()[] is an object with inheritance
support, so has hidden metatdata. I was not sure of that myself before.