I had happened across How To Remotely Monitor Memory Usage and smiled when I saw this :
As one example of this phenomenon, the SUSE Linux system that I use for my public Web and e-mail server originally only had 512 MB of RAM. This should have been more than adequate for the lightweight load that I was expecting, but the system tools showed that the box was constantly running low on memory. And even after I bumped it up to a full gigabyte, the system still complained.
I had just gotten ready to add another gigabyte when I discovered that most of the memory was actually being consumed by SUSE's aggressive disk-caching algorithm. Every time I added more memory, the operating system drank it up for the disk cache. In reality I was nowhere near hitting any kind of memory limit for the applications themselves, even with just 512 MB.
"That's how Linux memory works", I thought to myself, "he should have
Well, yeah, he probably should have. That once again points out
the danger of assuming you know what's going on based upon your
knowledge of other systems. Being an expert at Solaris is helpful
with Linux but it can also lead you astray. The opposite
is just as true, of course.
But knowing something about "Linux" in general can also send you down the wrong path.
I said that's how Linux memory works, but that isn't necessarily
true either. The same article goes on to say:
RedHat and SUSE have substantially different algorithms when it comes to allocating cache memory. Where SUSE is very aggressive and tries to make full use of the available memory, RedHat leaves unused memory lying around in case it's suddenly needed by something.
So if you've "learned" that Linux uses available memory for buffer caching,
a RedHat system that doesn't could confuse you. But wait - that's
"Swappiness" was introduced in 2.6 kernels. When some program wants more
ram and the kernel has a bunch being used for caching, it could give
up some of that. Or it could just make some other less active
program swap out to disk. Which is a better idea? Well, of
course that depends on what is going on right now. If there is heavy
disk activity and programs that really aren't being used, it would
make sense to swap. If there isn't much disk activity, or those swappable
programs are apt to become active very soon, it makes sense to
give back memory.
The idea was that the admin knows best what his system might require,
so the admin should be able to say how much "swappiness" is desirable.
If swappiness was set to zero (echo 0 >/proc/sys/vm/swappiness), the
kernel would give up cache to anything that wanted ram; if it
were set to 100 it would do the opposite and let the
Well, great, but what if you don't have a clue because sometimes
your system has unused apps and sometimes it doesn't.? No
problem, somebody came up with something that would make
a good guess on the fly: Autoregulated VM Swappiness Patch.
"[The] amount of swap space consumed is also taken into account, and the size of it compared to the physical ram is taken into consideration when making its effect on the value of swappiness. With this patch, this should make any machine that has swapspace as resistant to OOM as possible. This version by default autoregulates the swappiness, but also allows you to choose a manual setting if you so desire by echo 0 > /proc/sys/vm/autoswappiness and then setting the swappiness the manual way as previously. This makes comparison with autoregulation easy."
But then: (
Bugzilla Bug 54560):
As of 2.6.7, gentoo-dev-sources no longer contains the Con Kolivas
autoregulated swappiness patch. This is important for desktop machines, to
avoid having large amounts of memory swapped out on prolonged system inactivity
(causing an annoying swapstorm when the machine is used again).
Desktops and laptops are apt to sit unused for long periods. Therefore
unused processes tend to get swapped. If
the kernel were really smart, it would notice that *nothing* of
importance is happening and just leave things as is, but apparently
we haven't reached that point yet. Or if we could have so much
real physical ram that we could eliminate swapping entirely..
Well, the minute you say "eliminate swap", someone will
point out that you *need* swap. There's a long discussion of swap and ram at Kernel trap: Is Swap Necessary?,
but most of the conversation there is at cross-purposes. For
multi-user machines, you definitely want swap because you want to
be able to be truly interactive: moving one program aside so that
another can run. But for a single user machine, you may not want
to swap: it might be preferable to have the system refuse to start up
a new app and let you decide what you'd rather get rid of to make room
Or maybe not. I'm in favor of control, but the default probably
should be to swap. Then again, maybe the default for desktops
and laptops should be different.. it remains a complicated
and difficult subject.
If this page was useful to you, please help others find it:
More Articles by Anthony Lawrence
- Find me on Google+
Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site:
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.
Publishing your articles here
Jump to Comments
Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.
I am a Kerio reseller. Articles here related to Kerio products reflect my honest opinion, but I do have an obvious interest in selling those products also.
Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.
We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.