Memory Alignment

Noun · Development

Definitions

  1. The requirement or practice of placing data in memory at addresses that are multiples of the data type's size (e.g., a 4-byte int at an address divisible by 4). Misaligned access can cause hardware faults on some architectures or significant performance penalties on others due to extra bus cycles.

    In plain English: Placing data at specific memory addresses the processor can access efficiently, even if that means leaving small gaps between values.

    Example: "The struct has 3 bytes of padding after the bool field — the compiler inserted it to maintain 4-byte alignment for the next int."

Related Terms