Because R (my favorite
statistical software package) is very memory hungry, I need an
operating system that makes the most efficient use of memory (RAM).
One of the most widely touted benefits of GNU/Linux is that it utilizes
memory far more efficiently than Microsoft Windows, but I have never
seen that assertion put to the test.
To test the
hypothesis, I decided to compare the memory utilization of each
operating system on the same computer after a clean reboot. I also
decided to start R prior to taking my measurements, so that I would
have a rough idea of how much memory is available for my data.
The computer I used for the comparison is a Compaq Presario 1210 notebook (vintage 2001)
with 320 MB of RAM and a 1.0 Ghz AMD Athlon 4 processor. The computer has
two operating systems: a recently reinstalled version of MS Windows ME
and Debian Etch (the most recent stable version of Debian's GNU/Linux operating system).
Because MS Windows ME was released in Sept. 2000, it was designed for
computers that are rather "small" by today's standards and therefore utilizes far less memory than MS Windows XP and Vista.
To further increase Microsoft's edge, I disabled the virus scanner in
MS Windows, I saddled Debian down with KDE (the most memory-hungry
GNU/Linux desktop) and I ran the (bloated) stock Debian kernel (Linux
2.6.18).
Having been given all of the advantages, MS Windows should surely use less memory than GNU/Linux, right? ... Wrong!
Here's a snapshot of the memory usage in MS Windows ME, immediately after restarting the computer and starting the R gui:
Here's a snapshot of the memory usage in Debian, immediately after restarting the computer, starting Emacs and starting R:
To interpret the tables above, compare the 115 MB of "Available
Physical Memory" in MS Windows ME to the 140 MB of "free" memory in
Debian. Even though we gave Microsoft every advantage, GNU/Linux still
uses 20 percent less memory!
More knowledgeable users will also notice that MS Windows ME has used
about 317 MB of virtual memory (1240 - 923 = 317), whereas Debian has
not used any swap memory at all. (Virtual memory uses disk space to
extend the size of physical memory. Swap is a form of virtual memory).
In other words, MS Windows' memory requirements are so high that it
constantly has to shuffle blocks of data between physical memory and
the hard disk. By contrast, Debian hasn't had to "swap out" any data
yet.
Finally, it is worth discussing the first two lines of the output of
the "free" command. The first line indicates that, out of 322 MB of
RAM, 182 MB is in use. The next line subtracts "buffers" and
"cached" from the amount of memory in use and tells us that applications are only using 79 of the 182 MB in use.
What is occurring here is that GNU/Linux reads information
from disk only once and then keeps it in memory until it is no longer
needed. For example, now that you have loaded this webpage, you might
copy it into an email message, send it to a friend and then copy the
message into one of your mail folders. By reading the data once and
keeping it in memory (specifically, the buffer cache), GNU/Linux runs
faster because information is only read once.
To make the most efficient use of memory, GNU/Linux uses all free
RAM for buffer cache. When programs need more memory, GNU/Linux makes
the cache smaller by sending data (that it doesn't currently need)
to the swap partition. As we can see from the third line, GNU/Linux is
so light on system resources, that it has not had to send any data to
the swap partition yet!