[clug] Memory Leak In cAosity

Alex Satrapa grail at goldweb.com.au
Fri Aug 5 01:33:22 GMT 2005


On 4 Aug 2005, at 18:53, Sam Couter wrote:

> Linux uses all the memory it can. It's caching stuff so it doesn't  
> need
> to read from the disk next time you access it. It also caches stuff  
> that
> hasn't yet been written to the disk so it can order writes for better
> performance.

To explain using a concrete example:

[alex at mendel:~]
11:04 [0|2001]% free
              total       used       free     shared    buffers      
cached
Mem:        904428     889916      14512          0     141400      
176548
-/+ buffers/cache:     571968     332460
Swap:      1815336      48352    1766984


This means that my computer has a total of "904428"kB of RAM that the  
OS can use. The number "889916" means that I'm actually not getting  
my money's worth, since 904428-889916 kB of my RAM is not getting used!

Note the two values labeled "buffers" and "cached". As those numbers  
get bigger, it means Linux is holding more stuff in memory so that it  
doesn't need to access the disk as much - this is a performance  
optimisation: use more (fast) RAM to store stuff so you don't use the  
(slow) disk during normal operation.

If it wasn't for the buffers and cache being counted in the "used"  
value of 889916kB, then I'd find that only 571968kB of my RAM was  
being used. If that number in the second row under "used" is steadily  
increasing, you might have a problem. In such an instance, tools like  
ps and top might help you out by revealing applications which are  
individually consuming a lot of RAM, or a large number of small  
applications which are hanging around after they were supposed to  
exit (for example, a CGI script which forks a thread then never exits  
that fork).

I had a problem a while ago where something was chewing up memory to  
the point that my database was aborting many transactions due to lack  
of available RAM, and the Apache server was aborting many CGI scripts  
for the same reason - though to be technically correct, the kernel  
logs were telling me that Linux was simply terminating the biggest  
memory users. I was never able to figure out what was actually eating  
up the RAM - the problem mysteriously disappeared with the next "apt- 
get upgrade" and reboot - ps and top weren't telling me anything  
useful, the only symptom leading up to the out-of-memory warnings was  
a "used" value in the second row that was steadily increasing.

So if the number you see rapidly approaching 100% of available memory  
is that one immediately under "used", don't panic. If the number you  
see rapidly approaching 100% available is the one two rows down from  
"used", you have problems.

Alex Satrapa             M: +61 4 0770 5332
grail at goldweb.com.au     W: http://homepage.mac.com/alexsatrapa



-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 220 bytes
Desc: This is a digitally signed message part
Url : http://lists.samba.org/archive/linux/attachments/20050805/b1f4c737/PGP.bin


More information about the linux mailing list