Further memory question [was: Clear the computer's memory?]

Alan McKinnon alan at linuxholdings.co.za
Thu Mar 30 14:46:19 UTC 2006


On Thursday 30 March 2006 15:29, R Kimber wrote:
> On Thu, 30 Mar 2006 08:00:22 -0500

> It's not linux's behaviour that bothers me.  What I'm puzzled about
> is that when I boot up, linux will allocate memory as you describe,
> and Gkrellm will report an amount free. I'm not clear why this free
> amount should change so drastically after some hours of use, when
> caches etc have already been allocated and I'm not starting new
> apps.  At the moment, I still have about 1714MB free, but by
> tomorrow I'll bet it will be down to 700MB.  I don't usually use
> Firefox, BTW.

When you say "free", where do you get the figure from? I'm assuming a 
2G machine and after everything starts up it takes about 200-300M. A 
day later, 1200-1300M is in use. Well, that's about right - the 
kernel grabs chunks of memory that are not in use and uses them as 
disk buffers. This is OK, as if you start two vmware sessions needing 
lots of RAM it flushes the buffers and makes the RAM available. 
Meanwhile the kernel doesn't necessarily release memory used for 
buffers after they are synced - it might grab completely different 
pages for the next buffer and hold on to the previous one.

The kernel manages memory well, so well that you can't easily tell 
what's really going on. It's not obfuscation, it's just very dynamic. 
(You know all about it when you run out of RAM and swap, but the 
kernel can't prevent that for you.) It does it this way because a 
smart kernel will actively work to prevent heap fragmentation, make 
efficient use of caching techniques, and a host of other stuff that 
I'm clueless about :-)

Right now I have KDE, four desktops in the pager, 3 instances of 
konqueror, 3 konsoles, kmail and a vmware session all open. 117 
running processes:

alan at develop ~ $ ps ax | wc -l
117

Memory usage:
alan at develop ~ $ free -m
             total      used      free    shared   buffers    cached
Mem:           503       496         6         0        22       266
-/+ buffers/cache:       207       295
Swap:         2039       126      1913

These figures will go up and down during the day depending on how much 
work the machine is doing. But it seems like 295M RAM is available 
for use and vmware is mostly in swap. It changes dramatically when I 
work in the vmware session. But in general there's no need 
-- 
Alan McKinnon
alan at linuxholdings dot co dot za
+27 82, double three seven, one nine three five




More information about the ubuntu-users mailing list