Lectern

Search

Search IconIcon to open search

Memory management

Last updated Nov 7, 2022

Refers to the allocation of resources to each program by the operating system. Heavily involves the random access memory as a resource used by programs as a working space.

A memory manager has several tasks in particular:

The kernel is the part of the operating system always in the RAM as long as the computer is turned on.

# Memory address

A location, often in the form of a binary number, located on the memory. It can be referenced to access the content stored in-memory at that particular location. Starts from 0 to a maximum number defined by the amount of RAM in the computer.

To calculate the range of an address space provided the amount of RAM, given that $b$ is the number of bytes, find the number of bits $n$ by using $\frac {log(b)} {log(2)}$ and use that to find the maximum value ($\frac n 4$ Fs).

The number of bits an address has is dependent on the address bus’s width.

# Memory content

A particular address can store eight bits (one byte) of information; this information could be either a part of an instruction or data.

# Frames, pages, and page tables

Frames refer to compartments brought about due to the physical memory’s storage. Pages, on the other hand, are virtual and refer to references created by the CPU.

# Page tables

To bridge the link between frames and pages, memory managers often create a page table for each process. Page tables are data structures used by the memory manager to keep track of which page corresponds to which frame.

Page tables include a valid or invalid control bit which is used to tell whether or not a page is in the physical memory. In the case of demand paging, where data can be stored on the secondary storage temporarily, the control bit will be 0 (demarking it as not in the physical memory).

# Logical and physical memory

The logical memory is the memory as seen as pages (i.e., seen by the CPU). The logical memory stores pages by the CPU and can be purged at any time.

The physical memory is the memory stored as-is physically, and is seen as frames.

# Virtual memory and demand paging

Multiple programs may be loaded into the physical memory at once (in multi-tasking operating systems). The total memory size required by the OS and all the programs may exceed the physical memory size; in this event, the OS uses virtual memory to compensate. This space is known as a swap space; on Linux, this space is a partition called swap while on Windows, this space is in a file named pagefile.sys.

Trashing refers to the excessive swapping of pages and data between the memory and secondary storage; this causes the program to operate more slowly.

A computer on low memory may exhibit several signs:

To resolve low memory, consider:

# resmon

resmon, or Resource Monitor, is a program introduced in Windows Vista allowing users to view realtime information about the resources on their computer (i.e., CPU, memory, disk, and network) and the processes using them. There are several terminologies to note for resmon.

TermDefinition
CommitThe total amount of physical memory and page file space allocated by Windows
Working setThe amount of physical memory used
ShareableThe amount of physical memory a process is sharing with other processes
PrivateThe amount of physical memory a process is using alone