Data alignment

Data alignment is the strategy of arranging data in main memory according to certain rules contributing to speed-up of access to them.

When working with memory microprocessors use a machine word of different sizes as a main unit. As a rule, the machine word equals 2^k bytes. When saving a data object into memory some field consisting of several bytes can intersect with the "natural boundary" of words in memory. Some processor models cannot address those data in memory which violate the boundaries of machine words. Others can address data without alignment but less effectively than when addressing the data within the full "machine word" in memory.

Data alignment is performed with the help of empty memory cells between data objects. It increase the size of the data structures but speeds up access to data.


Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++ and C#

goto PVS-Studio;