Linux Memory Usage

The first few lines of the top shell command will show memory stats for a Linux system.

[admin@pm1 pert]$ top
top - 18:57:48 up 134 days,  2:26,  2 users,  load average: 0.03, 0.01, 0.00
Tasks: 165 total,   1 running, 164 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0% us,  0.2% sy,  0.0% ni, 99.8% id,  0.0% wa,  0.0% hi,  0.0% si
Mem:    514348k total,   478304k used,    36044k free,   169284k buffers
Swap:  2008104k total,      160k used,  2007944k free,    96696k cached

Note that the amount of truly free memory is probably much larger than the supposed 36MB indicated - much of the so-called used memory is in fact available for processes to use. The kernel uses a large part of RAM as cache ("buffers" + "cached"). A better indication is the swap space, which is almost all free. A sure sign of memory problems is when the system starts "thrashing" i.e. when it constantly needs to move pages from memory to swap space and replace them with other pages from swap space. This indicates that the "working set" (the memory pages that are actively used by all processes) is larger than physical memory can hold. You can tell when this is happening when the si/so columns ("swap in", "swap out") of vmstat show a lot of activity. (The example below shows a lightly loaded system).

[pert@pm1 ~]$ /usr/bin/vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
 0  0    160  26112 165664 129696    0    0     0     8    3     0  0  0 100  0

-- TobyRodwell - 12 Jun 2006

Topic revision: r2 - 2006-06-14 - SimonLeinen
 
GÉANT
Copyright © 2004-2009 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.