C++ Memory Visualizer — Scientifically Accurate Edition

Explore low-level memory allocation with real alignment, padding, and stack direction

Variable Declaration

ALIGNMENT Each type has a required alignment. int must start at an address divisible by 4; double by 8; short by 2. The compiler inserts padding bytes (shown as hatched cells) to satisfy these requirements — this is why sizeof(struct) can be larger than the sum of its members.
STACK DIRECTION On x86-64, the stack grows toward lower addresses. New variables appear at smaller addresses (right side of grid). High addresses are at the left.
ENDIANNESS x86 is little-endian: the least-significant byte is stored at the lowest address. For int x = 0x0A0B0C0D, you'll see bytes: 0D 0C 0B 0A at increasing addresses.
Code Visualization
// Declare variables on the left to see code here...
Variable Table
Variable Type Address Alignment Size Value Bytes (little-endian) Action
No variables declared yet

Memory Layout (256 bytes — stack segment)
High addresses ←————————————————————————————————→ Low addresses         ← Stack grows this way (new variables allocated here)
Legend
Variable bytes
Alignment padding (compiler-inserted)
Unused / unallocated
Symbol Table
No variables allocated
Memory Grid (256 bytes · addresses decrease left→right)