Introduction to Programming Languages/Memory Management
The memory in a computer is organized in a hierarchical way. The lowest level memory unit is a register, followed by the cache memory, then the RAM, hard driver, and so on. This organization of the computer's memory is specially useful because most programs need more memory than they are supposed to use.
Program variables are the link between abstractions represented by a program and the computer physical memory units. For instance, in C, you can use the keyword `register` to give the compiler a hint that a variable will be frequently used.
The compiler (or the Operating System, for that matter) can put variables in one of three places within the program's memory: static memory, stack, or heap. The following sections will cover with more details these three types of memory.