LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Swap confusion from Top and Free Outputs (http://www.linuxquestions.org/questions/linux-newbie-8/swap-confusion-from-top-and-free-outputs-4175470202/)

Rohit_4739 07-19-2013 08:39 AM

Swap confusion from Top and Free Outputs
 
Hi All,

I am not sure how to put this and i am kind of feeling embarrassed also asking this question because i think i should have known this, anyways here it is.

Code:

# free -m
            total      used      free    shared    buffers    cached
Mem:          5834      4413      1421          0        436      2455
-/+ buffers/cache:      1521      4313
Swap:        2047          0      2047
root@dbsrs0004:/root

***************************************************************
 PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  SWAP COMMAND
12194 oracle    -2  0 2274m  16m  14m S  0.0  0.3  0:00.40 2.2g oracle
12198 oracle    15  0 2275m  17m  15m S  0.0  0.3  0:00.03 2.2g oracle
12192 oracle    15  0 2274m  17m  14m S  0.0  0.3  0:00.22 2.2g oracle
 4824 oracle    15  0 2275m  19m  16m S  0.0  0.3  0:00.46 2.2g oracle

Why there is a difference in the output, the server's swap usage is 0 so why Top shows the oracle swapping out 2.2g and more over how could that even be possible as the Total swap on the system is 2G.

I am sorry if there is something silly in the question.:(

jonesr 07-19-2013 03:49 PM

The SWAP column in top shows VIRT minus RES and reflects the amount that might be swapped if the processes were to try to actually occupy all 2274m of the virtual address space. Since there are no pages allocated to the vast majority of that 2274m of mostly-empty virtual space, nothing needs to be swapped, and the free command rightly shows zero swap used.

jpollard 07-19-2013 05:06 PM

Swapping activity is also not limited to the swap file/partition. It is entirely possible for the system to drop pages from memory where the program code hasn't been used, and page in other program code from the disk resident program file. This is an ambiguous report from top, as it defines swap this way (ref manpage on top):

Code:

p: SWAP  --  Swapped size (kb)
          The non-resident portion of a task's address space.

So a large executable is likely not entirely in memory - thus non-resident, and added to "swap size".


All times are GMT -5. The time now is 11:02 PM.