LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Question about top (https://www.linuxquestions.org/questions/linux-newbie-8/question-about-top-900664/)

kdelover 09-02-2011 02:19 AM

Question about top
 
Free command shows the following output for swap.

Code:

Swap:        7820        518      7302
Used is 518 Megs.

If i do a top and sort the list by swap usage i see something like this:

Code:

3.8  1:28.33 407m java
7.0  24:10.62 360m firefox-bin
0.0  0:00.08 267m evolution-data-
0  0.0  0:00.07 265m evolution-data-
0  0.0  0:00.06 265m evolution-data-
0  0.0  0:00.05 263m evolution-data-
0  0.0  0:00.06 262m evolution-data-
0  0.0  0:00.06 261m evolution-data-

..so on..

so what exactly is this 407m 360m,265 m e.t.c ? And what is the m over here?is it megabytes or megabits? The man page of top says:
Code:


SWAP  --  Swapped size (kb)
          The swapped out portion of a task's total virtual memory image.

Basically i want to know what are the pages and what process do they belong to ,which are being swapped out.

Thanks !

xeleema 09-02-2011 02:41 AM

Greetingz!

First rule: 'top' lies. Anything having to do with RAM, Swap, threads, CPU usage, etc is an aggregate of all parent-child processes.

This is further exacerbated by the fact that a system doesn't exacty differentiate between real RAM and disk-based "swap". Systems only care about "memory" (which is what both RAM and swap are...just memory).

Example:
I'm not using any swap...according to 'free -m'
Code:

luser@server(Linux)$ free -m|egrep "tot|Swa"
        total  used  free
Swap:    4095    0  4095
luser@server(Linux)$

But top lies. It lies so bad that it lies to us *twice*.
Once in the swap usage it states right under "mem", and again when we tell it to list swap usage (see red text);

Code:

top - 23:37:04 up 65 days, 17:29,  3 users,  load average: 0.02, 0.02, 0.01
Tasks: 186 total,  1 running, 181 sleeping,  0 stopped,  4 zombie
Cpu(s):  0.3%us,  0.6%sy,  0.0%ni, 99.0%id,  0.1%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  8174592k total,  4357676k used,  3816916k free,  370596k buffers
Swap:  4194296k total,      412k used,  4193884k free,  3578100k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  SWAP COMMAND                       
 3868 nscd      15  0  307m 2848 1620 S  0.0  0.0  1154:47 304m nscd                           
 7278 sdmigr    15  0  234m 7260 2844 S  0.0  0.1  0:00.27 227m httpd                         
 7270 sdmigr    15  0  234m 7316 2868 S  0.0  0.1  0:00.24 227m httpd                         
 7272 sdmigr    15  0  234m 7316 2876 S  0.0  0.1  0:00.17 227m httpd                         
 7276 sdmigr    15  0  234m 7328 2848 S  0.0  0.1  0:00.34 227m httpd                         
 7268 sdmigr    15  0  234m 7332 2884 S  0.0  0.1  0:00.25 227m httpd                         
 7263 sdmigr    15  0  234m 7356 2836 S  0.0  0.1  0:00.25 227m httpd                         
 7266 sdmigr    15  0  234m 7372 2864 S  0.0  0.1  0:00.21 227m httpd                         
 7264 sdmigr    15  0  234m 7380 2884 S  0.0  0.1  0:00.37 227m httpd                         
15416 root      15  0  233m 9.9m 5924 S  0.0  0.1  0:01.81 223m httpd                         
21754 mysql    18  0  185m  24m 4888 S  0.0  0.3  0:23.86 161m mysqld


kdelover 09-02-2011 02:49 AM

For me the swap usage in top and free is pretty much the same,i do not see a huge difference though.But back to my question what is m under the swap column of top ?megabits or megabytes? currently,my swap used is 279 MB & in top i see around atleast a dozen of processes with swap values as 100m,150m,519m e.t.c ..if i total this up,that would be more than 279 MB.

kirukan 09-02-2011 02:59 AM

From top output, i think you refer VIRT, VIRT = SWAP + RES. it means swap + physical memory used by task
To refer memory paging,
http://en.wikipedia.org/wiki/Paging


All times are GMT -5. The time now is 10:56 PM.