Class instance memory overhead lower than 3 words?

Steven Schveighoffer schveiguy at yahoo.com
Fri Jan 26 20:33:06 UTC 2018


On 1/24/18 4:48 PM, Nordlöw wrote:
> Why is the memory overhead for a class instance as high as 3 words (24 
> bytes on 64-bit systems? I find that annoyingly much for my knowledge 
> database application. I'm aware of extern(C++), having one word 
> overhead, but such extern(C++)-classes cannot use all of D; I get 
> compilation errors such as
> 
> node.d(99,25): Error: Internal Compiler Error: type `inout(Edge)[]` can 
> not be mapped to C++

Should be 2 words, the monitor and the typeinfo pointer. What is the 3rd 
one?

On 64-bit macos:

class C
{
}

void main()
{
    import std.stdio;
    writeln(typeid(C).initializer.length); // 16
}

-Steve


More information about the Digitalmars-d-learn mailing list