domingo, 19 de febrero de 2012

Top shows incorrect amount of memory in use

Just in case that there's someone as clueless as i was... "top" command lies about your memory usage with "new" kernels (2.6.x series) .Let me explain how this game works. 

jupiter:/disponible/cargaMasivaDesa # top
Tasks: 108 total,   1 running, 105 sleeping,   2 stopped,   0 zombie
Cpu0  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu1  :  0.0%us,  1.0%sy,  0.0%ni, 99.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   6127780k total,  6072248k used,    55532k free,   297820k buffers
Swap:  2096472k total,     3320k used,  2093152k free,  3969068k cached

After a reboot everything seems in place, I mean you can "top" and watch your memory report correctly but after some hours (in my case more or less a day) you'll see that almost your memory is gone. But if you calm your nerves you'll see that counting process and the memory used by them will report that your memory is okey... So???

It seems that the important info is not on free/used fields reported by this tool. The stuff that really matters is in /proc/meminfo.

 jupiter:/disponible/cargaMasivaDesa # cat /proc/meminfo
MemTotal:        6127780 kB
MemFree:           56568 kB
Buffers:          297864 kB
Cached:          3865668 kB
SwapCached:         1268 kB
Active:          2135488 kB
Inactive:        3655580 kB

Active: means memory in used

Inactive: means memory free but not available

Now i can sleep better!! . For more information you can have  a look to the following articles:

http://www.netadmintools.com/art416.html

http://www.tldp.org/LDP/tlk/mm/memory.html

Cheers

P.S: memory reporting command by process

 ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r | head -10

No hay comentarios:

Publicar un comentario