Memory Fundamentals

1 / 4

Process Memory

Stack    ← Local variables, grows down
   ↓
Unused
   ↑
Heap     ← malloc lives here, grows up
BSS      ← Uninitialized globals
Data     ← Initialized globals
Text     ← Code
2 / 4

The Program Break

  • Boundary between heap and unmapped memory
  • sbrk(0) returns current break
  • sbrk(n) extends heap by n bytes
  • Returns (void*)-1 on failure, NOT NULL
3 / 4

Why Build Our Own Allocator?

sbrk alone cannot:

  • Free memory in the middle
  • Reuse freed memory
  • Track allocation sizes

We need metadata and block management.

4 / 4
Use arrow keys or click edges to navigate. Press H to toggle help, F for fullscreen.