I have addressed similar problems using a typed array of contiguous memory and another array of lengths.
Re:Go does not need a Java-style GC
by marginalia_nu on Wednesday November 24, 2021 @03:30PM
(#29334759)
I did try exactly that, but the GC overhead was still prohibitively high for my use case, made because big arrays in practice are composed from shorter non-contiguous arrays to make garbage collection even remotely possible.
I could have gotten 10 times as much hardware instead, but that would be an incredible waste of money compared to just spending a few days writing more hardware-efficient code.