ABSTRACT

Chapter 2 describes one type of memory: stack memory (also called the call stack). Stack memory follows a simple rule: first in, last out. The call stack is automatically managed by the code generated by the compiler. Every time a function is called, a new frame is pushed. Every time a function ends, the frame is popped. Programmers have no direct control over this process. One consequence is that a function may read from or write to memory addresses in lower frames; however, a function can never “look upward” into memory above its frame. This is because whenever a function is actively executing, there are not valid memory addresses “above” it.