Heap memory
Drawn to scale, the whole 4096-byte heap. The 100-byte chunks are thin slivers.
16KB
17KB
18KB
19KB
20KB
Zoomed in, byte addresses on the left, pointers on the right.
- Header (size, magic)
- Free-list node (size, next)
- Data in use by a, b, c
- Free space
20480
Program
Inside the 8 bytes
// while allocated typedef struct { int size; // 4 bytes int magic; // 4 bytes } header_t; // while free typedef struct __node_t { int size; struct __node_t *next; } node_t;
Free list
Variables
Keyboard: ← → to step, Space to play or pause.