should data stored in virtual address space (using VirtualAlloc()) be aligned? If so how should I store structures in virtual address space so that they are properly aligned?
should data stored in virtual address space (using VirtualAlloc()) be aligned? If so how should I store structures in virtual address space so that they are properly aligned?
that's because the OS takes care to align data accessed by the CPU whenever it writes/reads variables in dynamic memory?
And if I use VirtualLock() to bring a region of address space in physical memory, do I have to worry about having data aligned?
The compiler will take care of aligning things. The CPU can read/write unaligned data too (on x86), but may take a performance hit.
But if you are using VirtualAlloc, then it is best to align on a 4-byte boundary since you're basically working with pages the compiler won't be able to help.
VirtualAlloc also works on pages. You only have to worry about the correct page boundary to make it work. The rest of the data should preferably be aligned, but even if not, it will work, but not always optimally.And if I use VirtualLock() to bring a region of address space in physical memory, do I have to worry about having data aligned?