Open dbechrd opened 7 years ago
That is correct, but the Allocator neither by name nor description implies that it returns an aligned block of memory. It just happens to use the _aligned_malloc function.
Agreed, just pointing it out. Feel free to close if not considered a bug. :)
I believe your memory allocater does not align memory properly. https://github.com/TheCherno/Sparky/blob/master/Sparky-core/src/sp/system/Allocator.cpp
The Allocate method:
void* Allocator::Allocate(size_t size)
calls _aligned_malloc on line 24:
byte* result = (byte*)SP_ALLOC(actualSize);
then proceeds to misalign the memory on line 27 before returning it to the caller:
The alignment needs to take the size_t preamble into account to ensure that the pointer returned to the caller is properly aligned. For an example of doing this properly, see: https://blog.molecular-matters.com/2012/08/27/memory-allocation-strategies-a-stack-like-lifo-allocator/