# Memory Management

* handles or manages primary memory. It moves processes back and forth between the main memory and the disk during execution.
* keeps track of each and every memory location, regardless of whether it is allocated to some process or free.
* It checks how much memory is to be allocated to processes.
* It decides which process will get memory at what time.
* it tracks whenever memory gets freed up or unallocated, and correspondingly updates the status.
* The process address space is the set of logical addresses that a process references in its code.
  * For example, when 32-bit addressing is in use, addresses can range from 0 to 0x7fffffff; that is, ²³¹ possible numbers, for a total theoretical size of 2 gigabytes.
* The operating system takes care of mapping the logical addresses to physical addresses at the time of memory allocation to the program. There are three types of addresses used in a program before and after memory is allocated:
  * Symbolic addresses:
    * The addresses used in a source code.
    * The variable names, constants, and instruction labels are the basic elements of the symbolic address space.
  * Relative addresses:
    * At the time of compilation, a compiler converts symbolic addresses into relative addresses.
  * Physical addresses:
    * The loader generates these addresses at the time when a program is loaded into main memory.
* Virtual and physical addresses are the same in compile-time and load-time address binding schemes.
* Virtual and physical addresses differ in execution-time address-binding schemes.
* The set of all logical addresses generated by a program is referred to as a logical address space.
* The set of all physical addresses corresponding to these logical addresses is referred to as a physical address space.
