‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Saturday, 23 November 2019 13:54, S.G via D.gnu <d.gnu@puremagic.com> wrote: > Thanks for the quick replying, even if a bit disapointing. > > The reason why I asked is because I'd like to avoid cases where > the enum type is used directly and that creates an alignment > issue that implies memory overhead, i.e > > enum SomeEnumeratedType // could be `ubyte` or `unsigned char` > { > member1, member2, member3 > } > > class Stuff > { > ubyte[7] allTheOtherMembers; //let's say > SomeEnumeratedType someEnumeratedType // now a Stuff instance > takes 16 bytes > // because > SomeEnumeratedType takes 4 bytes... > }
Understood, however for AST data structures in the D language frontend, I don't think such field packing would really make any valuable difference on memory. If the fields are arranged to not have a needless amount of alignment holes in the middle, such as: class Expression { ubyte op; // <-- up to 7 bytes padding inserted here. Type* type; ubyte size; ubyte parens; // <-- up to 6 bytes padding inserted here. Loc loc; } Then the best improvements one can make would be in relation to memory consumption is either better GC management or add more scope destruction (in my opinion). -- Iain