Guided Notes
Dynamic Memory Management
Stack vs heap, malloc, calloc, realloc, and free, checking for NULL, memory leaks, and dangling pointers.
Stack and heap
Slide 1 / 5| Stack | Heap | |
|---|---|---|
| Holds | Local variables, function calls | Memory you request at run time |
| Size | Small (often ~8 MB) | Large — most of RAM |
| Lifetime | Freed automatically when a function returns | Until you call free() |
| Managed by | The compiler | You (malloc / free) |
