There are functions like _aligned_malloc for C and C++ but I can't find anything for aligning .NET objects in memory.
It is not possible in the general case to usefully align a .net object on a 64-bit boundary, because even if an object starts out on a 64-bit boundary there's no guarantee that it won't be relocated to an odd multiple of 32 bits. For some reason, .net seems to think it's worthwhile to force arrays of more than a thousand double values to the Large Object Heap, which is always 64-bit aligned but is otherwise horrible, and yet provides no useful means of requesting 64-bit alignment for other objects even though doing so should not be difficult or costly (round up object sizes in gen0; when moving objects to higher-numbered generations, pair up odd-sized objects).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With