Finalizers, Destructors, RAII, GC
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Fri Apr 30 10:52:42 UTC 2021
On Friday, 30 April 2021 at 10:44:07 UTC, Ola Fosheim Grøstad
wrote:
> On Thursday, 29 April 2021 at 15:11:06 UTC, Imperatorn wrote:
>> 1. What's bad about the implementation (haven't looked)?
>
> From the ABI:
>
>>An interface is a pointer to a pointer to a vtbl[]. The vtbl[0]
>>entry is a pointer to the corresponding instance of the
>>object.Interface class. The rest of the vtbl[1..$] entries are
>>pointers to the virtual functions implemented by that
>>interface, in the order that they were declared.
The bad part is made more explicit here:
https://dlang.org/spec/abi.html#classes
As you can see, every object wastes 8 bytes per interface it
supports. Ok if you only have 100 instances, not good if you have
one million instances (would waste 8 megabytes per interface you
support).
More information about the Digitalmars-d
mailing list