Memory Alignment

Memory Alignment of the C language,

When the compiler to allocate memory for a variable, the variable is always the first address of a multiple of the number of bytes. For example, in a 64-bit address space, a total of 8 bytes, char type is always 8 bytes can be randomly distributed. And 4 bytes of type int, if in this space, the first three bytes are occupied char type, it does not allocate memory for an int followed by a fourth byte allocated memory, but from the 5th Kai bytes allocated memory. This is the memory alignment manipulation.

Memory Alignment Although waste memory space segment, but will reduce the number of CPU to access memory, enhance the running speed.

Guess you like

Origin www.cnblogs.com/lunar-ubuntu/p/12324547.html