  | |  | Red Hat Enterprise WS 3 update 5 memory cache problem? | Red Hat Enterprise WS 3 update 5 memory cache problem? 2005-08-04 - By John Haxby
Back Comot KL wrote:
>Thanks for the reply. May be I explain it wrong. But >anyway, below is my free -m without any prgrams >running > > >ml02{pm}% free -m > total used free shared >buffers cached >Mem: 15499 15467 32 0 > 44 13735 >-/+ buffers/cache: 1688 13811 >Swap: 2047 0 2047 >ml02{pm}% > >How am I going to get back my memory? > > No, you're not explaining it wrong. What you think you want is perhaps something like this:
total used free shared buffers cached Mem: 15499 15467 13767 0 44 0
That's not perhaps unreasonable, but what are you going to do with that free memory? All it's doing now is heating up the room. Sure when you run programs they'll use some of that free memory and put it back when it's finished.
What happens, though, when those programs want to access files? Suppose you run "date" (not a large program, I'll grant you). Date (on my system) open (and presumably reads a bit) eight files and looks for a further 25. There's nothing in the cache, so if you look at the disk light you'll see it flicker when you run the date command, every time you run the date command.
Perhaps a different example of something I do on a regular basis will illustrate the use of the cache: I frequently do "find -type f -name '*.[ch]' | xargs grep foo" at the root of a tree where there are some 300M of files. The first time I run that command it takes an about 25s; the second time it takes 2s, then 1.5s. Actually, when I tried it just now, it took 1.5s so I got those numbers from running the same find|grep in a different source tree about the same size. I've got enough memory to hold both source trees in memory at once.
Now what happens when I do a build? Well, I don't have quite enough memory to hold all the source files, all the object files and all the working space for the compiler, make, etc.
Is the machine any slower because the free memory isn't there? No. Is it quicker becuase a lot of stuff is cached? You bet it is -- it's enormously quicker.
Unlike some operating systems, Linux *uses* all the memory available. Anything that has no immediate pressing need is used to store stuff that was recently read from the disk. It makes a *huge* difference. The only time you should have a large amount on the free list is shortly after booting (when not much has happened) and just after a large program has exited. You really want the amount of memory reported as free to be low.
jch
-- Taroon-list mailing list Taroon-list@(protected) http://www.redhat.com/mailman/listinfo/taroon-list
Earn $52 per hosting referral at Lunarpages.
|
|
 |