There isn’t always 16-byte overhead(?). See: Essentials · The Julia Language and on isbitstype Essentials · The Julia Language
Return
true
if typeT
is a “plain data” type, meaning it is immutable and contains no references to other values, onlyprimitive
types and otherisbitstype
types.
My understanding is that there’s no overhead when such types are stack allocated, i.e. (almost) always. And even with an array of such, then 16-byte overhead seems rather low for the whole array (then there’s StaticArrays.jl for no overhead where it applies, and also for tuples of?), if that’s what it really is.
A destructor as in C++ might change things (I’m not sure about finalizers), but making Julia a very different language without without garbage collection (it’s still possible to do your own memory management). For e.g. strings you actually want GC (for long strings), rather than finalizers/destructors and (naively) copying:
I would be rather happy with only 16-byte overhead (memory is cheap), for say strings, as the (64-bit) pointer is 8 bytes, and you need to store the length somehow. I’m more worried about the pointer-indirection, what I believe ShortString.jl (and FixedSizeString.jl) solve. I actually had the same idea as others, described here (and nothing in the way to do it, if not already done), to make more general: