Prev | Next |
Here, we ask not what to store in the memory, but where to store it, and how to keep track of what memory is used and what is vacant.
Static allocation |
---|
Early versions of Fortran use static allocation. The idea is that every variable, including local variables of functions, are allocated when the program is loaded into memory. Nothing ever moves, and the size of the program's data are is fixed. |
Stack allocation |
---|
Algol 60 introduced stack allocation, which stores local variables of functions (and some additional information) into the run-time stack. The stack grows and shrinks as the program runs. Each time a function is called, it gets space in the run-time stack for its information. When the function returns, all of its space is deallocated. |
Heap allocation | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Later programming languages introduced the heap, where programs can allocate data that stays around longer than the function that did the allocation. There are two ways to manage the heap, manually or automatically.
|
Prev | Next |