I had happened across How To Remotely Monitor Memory Usage and smiled when I saw this :
"That's how Linux memory works", I thought to myself, "he should have known that."
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:
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 not all.
"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 processes swap.
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.
But then: ( Bugzilla Bug 54560):
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 for it.
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.
Got something to add? Send me email.
More Articles by Anthony Lawrence © 2011-03-26 Anthony Lawrence
Your computer needn't be the first thing your see in the morning and the last thing you see at night. (Simon Mainwaring)
Sat Jun 17 22:31:58 2006: 2126 drag
Ya.. this was a huge deal for a long time. People bitching about how when they would come back to their machines after a few hours of inactivity would watch the machine chug a bit as they openned up Mozilla and everything came back to life.
One of the deals is, however, that as your gone the machine still does have activity. Not a big deal, but you have your hourly and daily cron job. For instance you run updatedb which builds your man file database and 'locate' command database and such. So there is always something going on.
So I think that 'swapiness' was a sort of a comprimize. People would complain and kernel developers would say something along the lines of "What you want isn't going to do what you think it will do and your not going to like it". But even then it makes sense to regulate it somewhat so users could set the swapiness to 'unswap' or whatever and find out for themselves.
I learned memory management the 'wrong way' with messing around with Windows 95 and 98. I had to arrange it so that as much memory was free so it could be used for my games as possible. With Linux I tried the 'memory reduction' technics I learned from Windows 98 (remove unused services, strip down X, only run certain programs, pay carefull attention to memory usage) but then when I would do anything the memory usage would actually go up! I was a bit shocked.
But then I learned about operating systems that actually have effective memory management and Linux's 'Unused memory is wasted memory' concept and it all made sense.
Nowadays to me the most efficient memory management is about how much RAM you can use and still never have to access harddrive swap during heavy use.
------------------------
Printer Friendly Version
Where's the memory? Copyright © June 2006 Tony Lawrence
Have you tried Searching this 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.
Contact us
Printer Friendly Version