In this article, we will talk about memory patterns and virtual memory.
Memory is one of the most important parts in our computer. In order for this important part to be managed by the operating system, it must be subjected to some memory settings by the operating system. In this article, we will take a closer look at the aforementioned memory patterns and what our computer does when the memory is full.
What is virtual memory?
It will be more useful if we learn what virtual memory is before moving on to the layouts. Virtual memory; When the memory is full in our computer, it is the place where the memory part that is not used by the idle processes is transferred. Virtual memory is a file or partition in your internal storage. The operating system will automatically adjust the virtual memory size if you do not make a setting manually. We recommend that you do not skip virtual memory, especially if you have an older computer.
Segmented memory model
Now that we know what virtual memory is, we can start with the fragmented memory model. In the granular memory model, different processes will take up different sizes of memory space. These are the pieces we talked about segment known as. These parts take up the size of the program. The operating system knows the starting point of each piece of process and how big it is.
Let’s assume after a while the memory is full.
If the user tries to open more applications, some applications need to be unloaded and free up. In this case, the operating system continues to run idle processes in the background by passing those processes to virtual memory.
Then, the application you tried to open passes to the idle place, if it fits.
In the segmented memory model, there are different parts of the applications. These;
- Program parts are the part that contains the application code. It contains the functions and classes of the program.
- Data pieces are where application data is kept. It contains variables and data structures.
Disadvantages of the segmented memory model
- In the segmented memory model, there is a lot of space between parts. This memory fragmentation It is called. Therefore, memory cannot be used very efficiently.
- Large parts, usually not accepted into memory.
Both of these problems can be overcome to some extent by compressing parts that are already in memory.
Paged memory model
Now that we see the segmented memory model, we can look at the paged memory model. As we know from the fragmented memory model; the application considers all memory to be its own. The operating system pretends to allow it. The application’s perspective on memory logical memory called.
Things are not like that in our main memory. The memory space occupied by each process varies according to the processor architecture. to pages It is divided. This area is in x86 architecture 4 KB corresponds to the size. A page can contain a program, if it fits, it can host more than one program, or it can contain data belonging to only one program. These pages, as the operating system decidescan happen anywhere in memory. Also, some pages may be in virtual memory.
In the model, we see how the application sees the memory (left rectangle) and how the operating system separates the application page by page using the page table (small rectangle in the middle). In the right rectangle, we see how it is addressed in physical memory.
Which memory management style is better?
Both orders have their own pros and cons.
- The segmented layout puts all the code of the program in memory, convenient to the processor, which provides quick access to the program. But also to memory fragmentation and this means less efficient use of free space. Also, in a granular order, large operations often cannot enter memory.
- In the paged layout, the program code is fragmented and put into memory, which provides a slower access than the fragmented layout. However, he is quite capable of using free space and memory fragmentation eliminates the possibility. Paged memory layout is used in Windows.
- Some processors support both layouts. Pieces consist of several blocks of definite size.
If you have a question mark in your mind, Technopat SocialYou can open a topic to.