Virtual Memory

nehpets0701
2 min readAug 25, 2021
Diagram of Virtual Memory

Memory, also known as RAM (random access memory), is where a computer stores information that is actively being used. This is not to be confused with storage, which is where long term items such as files, applications, and photos are stored. Virtual memory is a memory management technique in which physical memory is mapped into virtual addresses.

Virtual memory is divided into two main sections called the Stack, and the Heap, as seem below.

Organization of memory

The stack begins with the higher addresses and grows downwards as more memory is allocated. The heap is broken up into sections called segments, and it grows starting from the lower memory addresses. The stack contains things such as command line arguments and environmental variables. The heap contains things like the program code and variables from said program.

One of the major advantages of using a virtual memory system such as this is that there can be many instances of virtual memory like this running in one set of physical memory. This allows for a system to have many processes running simultaneously, and so all of it can be understood in the same way. Each memory region can have its own mappings and permissions.

The operating system stores the mappings between physical and virtual memory in a data structure called a pagetable. In Linux for example, this is all stored in the /proc directory for each running process. This is an overview of how virtual memory works.

--

--