How is memory allocated for a vector of structs?

You could in theory Libc.malloc the structs yourself & unsafe_load the instances, at the cost of having to juggle lifetimes manually, but I wouldn’t recommend it. What’s the point of using a language that models mutability if we’re falling back to manually tracking everything ourselves again?

For mutable structs themselves, you’ll (generally) have to trust julia to do well, though the question is if you really need mutable structs in the first place. If they’re immutable and isbits (i.e. they don’t contain pointers/mutable data), the struct will be allocated inline in the array.

1 Like