Class instance memory overhead lower than 3 words?
kinke
noone at nowhere.com
Thu Jan 25 23:32:25 UTC 2018
On Wednesday, 24 January 2018 at 21:48:21 UTC, 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++
If you don't need C++ interop and only care about getting rid of
the monitor pointer, you can declare the class as C++ class but
use the D linkage/ABI for all functions, so that they accept D
slices:
extern(C++) class Node
{
extern(D):
void foo(Node[] nodes) {}
}
Is a struct not an option?
More information about the Digitalmars-d-learn
mailing list