I use Marshal.GlobalHAlloc to allocate memory. As the documentation says: "This method provides the Win32 LocalAlloc function from Kernel32.dll.". GlobalAlloc documentation says it will be aligned by 8 bytes, but LocalAlloc says nothing about alignment.
For example, I want to allocate 1024 bytes and make sure that it is aligned to 16. Will it work when I allocate 1024 + 16 bytes, then I check the% 16 pointer? If the result is 0, it means the memory is aligned when it is not equal to 0, I just increase the pointer to fit my expectations. The problem is that I donβt know if I aligned the pointer, is it really aligned in physical memory?
zgnilec
source share