Dynamic Memory: Heap Allocation in Assembly
Request and release memory at run time from assembly using the OS heap interfaces (brk/mmap on Linux, VirtualAlloc on Windows) and C library malloc/free.
Stack vs Heap
The stack holds fixed, scope-bound data and is automatically reclaimed. The heap provides dynamic memory whose size and lifetime you control at run time.
When You Need the Heap
Use heap memory when the size is unknown at assemble time or the data must outlive the procedure that created it, e.g. growing buffers and data structures.
All lessons in this course
- Virtual Memory Concepts
- Linux System Calls (syscalls)
- Windows API Interaction
- Dynamic Memory: Heap Allocation in Assembly