One interesting aspect about modern operating systems is the fact that they can run programs that require more memory than the system actually has. Like the Tardis in Dr. Who, Linux memory is much bigger on the inside than on the outside.
At the extreme end, this means that if your CPU is 32-bit (meaning that it has
The interesting thing is that when you sum the memory requirements of the programs you are running, you often reach far beyond the physical memory you have. Currently one of my system appears to need about 570 Mb. Although my machine only has 384 Mb. Surprisingly enough, I don’t notice any performance problems. So, how is this possible?
Well, Linux, Unix and many other operating systems take advantage of the fact that most programs don’t use all of the memory that they “require”, as you typically do not use every part of the program at once. For example, you might be using a word processor, but not currently using the spell checking feature, or printing function, so there is no need to keep these in memory at the same time. Also, while you are using your word processor, your email program is probably sitting around doing nothing.
From the user’s perspective the email program (or parts of the word processor) are loaded into memory. However, the system only loads what it needs. In some cases, they might all be in memory at once. However, if you load enough programs, you eventually reach a point where you have more programs than you have memory.
To solve this problem, Linux uses something called “virtual memory”. It’s virtual because it can use more than you actually have. In fact, with virtual memory you can use the whole 232 bytes. Basically, what this means is that you can run more programs at once without the need for buying more memory.
When a program starts, Linux does not load all of it, just the portion it takes to get started. An important aspect of virtual memory is keeping parts of the program that are not needed on the hard disk. As the process runs, when it finds it needs other parts of the program, it goes and gets them. Those parts that are never needed are never loaded and the system does not use all of the memory it appears to “require”.
If you have more data than physical memory, the system might store
it temporarily on the hard disk should it not be needed at the moment. The
process of moving data to and from the hard disk like this is called
In order to do all this, the system needs to manage your memory. This
function is logically called “memory management” and is one of the core aspects
of any modern operating system. Although the details are different from one
operating system to the next, the basic principles apply, even between
different
In other sections of the tutorial, we will talk about the details of memory management
from both the