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.
(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version
Increase ad revenue 50-250% with Ezoic
Inexpensive and informative Apple related e-books:
Photos for Mac: A Take Control Crash Course
Take Control of the Mac Command Line with Terminal, Second Edition
Take Control of Upgrading to El Capitan
Take control of Apple TV, Second Edition
Take Control of OS X Server