Virtual Memory Cheat Sheet
by, 10-27-2012 at 04:39 AM (3631 Views)
'Virtual' Memory is the mental model, or abstraction, that the programming language provides to the programmer to explain how computer memory is managed while you program is running. It is NOT the same as physical memory.
At run time, the operating system handles the translation from 'virtual' memory addresses to physical memory addresses, and the programmer does no need to be aware of this process.
This is referred to as the top.
Is called the Static Region because the contents of each location do not change while the program is running.
It contains the code for the program.
Also contains static data members.
The size of this region does not change.
This is referred to as the middle.
Is used for dynamically allocated storage, anything that is created with the keyword 'new'.
Storage in this region is reserved while the program is running.
The same location can be allocated once, then released, and then re-used for something else, over and over; all while the program is running.
NOT to be confused with the Abstract Data Type called 'heap'.
This is referred to as the bottom.
This is where local variables are stored.
Storage is reserved when the method is called, and released when the method exits.
Conceptually, storage is reserved from the bottom up.
When a method is called, the Stack 'grows'.
When a method exits, the Stack 'shrinks'.
Since the last method called is the next to exit, this is a Last-In First-Out Process.
The same location on the stack may be occupied by different variables throughout program execution.