[ale] top and SWAP

JK jknapka at kneuro.net
Fri Sep 7 11:00:54 EDT 2007


John Wells wrote:

> Guys,
> 
> Would like some help in clarifying the SWAP column under top

I believe (based on knowledge of the 2.4 series kernels) that
this reflects the amount of virtual memory owned by the process
whose backing store is the swap partition.  However, just because
a memory region is backed by swap does not mean it will ever
actually be *written out* to disk.  The "Used" number is the
amount of swap space actually in use on the disk.  If a swapped
region is never actually written to (a situation that is quite
common), it will never be physically present either in RAM or
on disk (it's *really* "virtual").  This is because swap is only
used to back anonymous (malloc()'d) memory, which is assumed to
be 0 if never written to. There's no reason to ever allocate
pages for 600MB of zeros; you only need real RAM or swap if the
process writes data to a page.

-- JK

> (you
> might have to add it to your view). For example, currently I see:
> 
> Tasks: 147 total,   4 running, 143 sleeping,   0 stopped,   0 zombie 
> Cpu(s):  0.2%us,  0.1%sy,  0.0%ni, 99.1%id,  0.0%wa,  0.0%hi,
> 0.6%si,  0.0%st Mem:   2074688k total,  1810620k used,   264068k
> free,   462408k buffers Swap:  4104568k total,        0k used,
> 4104568k free,   585468k cached
> 
> PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  SWAP
> COMMAND 10362 wellsj    23   0  851m 222m  27m S    0 11.0   0:44.24
> 629m java 8822 wellsj    18   0  647m  20m 6288 S    0  1.0   0:01.09
> 627m java 6895 www-data  24   0  225m 2304 1004 S    0  0.1   0:00.00
> 223m apache2 6897 www-data  23   0  225m 2308 1008 S    0  0.1
> 0:00.00 223m apache2 7093 wellsj    15   0  153m  30m  15m R    0
> 1.5   0:10.54 122m gnome-panel 7394 wellsj    15   0  334m 211m  23m
> S    0 10.5   7:58.76 122m firefox-bin 9809 wellsj    15   0  158m
> 51m  25m S    0  2.5   0:10.71 106m epiphany 6452 mysql     25   0
> 124m  20m 5012 S    0  1.0   0:00.19 104m mysqld 7099 wellsj    18
> 0 87028  18m  14m S    0  0.9   0:08.65  66m nautilus 7231 wellsj
> 15   0 63340 8708 7056 S    0  0.4   0:00.16  53m trashapplet 7277
> wellsj    16   0 65776  11m 9220 S    0  0.6   0:00.33  52m
> gweather-apple 7184 wellsj    15   0 58296 6368 5120 S    0  0.3
> 0:00.08  50m evolution-data 7444 wellsj    15   0 69272  20m  10m S
> 0  1.0   0:03.53  47m gnome-terminal
> 
> 
> Ok, so it appears that some processes are doing some heavy swapping.
> But, look above...in the header section. Swap: says there's a lot
> available, but *none* in use? Where's all that memory in SWAP
> disappearing to?
> 
> I suppose the "cached" memory might have something to do with it, but
> have found no good docs describing what it indicates yet. Given that,
> I'm hoping it's something obvious to a person with good virtual
> memory understanding and am off to read on Wikipedia. However, if
> *you* know, I'd appreciate your insight.
> 
> Thanks! John _______________________________________________ Ale
> mailing list Ale at ale.org http://www.ale.org/mailman/listinfo/ale
> 
> 


-- 
"What can be asserted without evidence can also be
dismissed without evidence." -- Christopher Hitchens



More information about the Ale mailing list