LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   swap calculation (http://www.linuxquestions.org/questions/linux-general-1/swap-calculation-744681/)

mario.almeida 08-03-2009 02:16 AM

swap calculation
 
Hi All,

Need to know how swap is calculated.

As per the manual of top it says

VIRT -- Virtual Image (kb)
The total amount of virtual memory used by the task. It includes all code, data and shared libraries plus pages that have been swapped out.

VIRT = SWAP + RES.

when checked with the output of top

Swap: 8385920k total, 0k used, 8385920k free, 2423716k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4466 aares00 24 0 4502m 2.8g 16m S 17.6 28.8 85:55.00 java

VIRT = 2.8g-4502m

VIRT=1635

if VIRT = 1635 then why does Swap used is 0k?

Please let me know what is my mistake

//Remy

GlennsPref 08-03-2009 02:34 AM

Hi, My guess is that you have enough ram for the tasks

you are running so the swap drive is empty, but ready for use.

Hope that helps, regards Glenn

mario.almeida 08-03-2009 08:06 AM

Quote:

Originally Posted by GlennsPref (Post 3629214)
Hi, My guess is that you have enough ram for the tasks

you are running so the swap drive is empty, but ready for use.

Hope that helps, regards Glenn

Hi Glenn,

Yes there is enough ram for the task

As you say "the swap drive is empty, but ready for use"
You mean swap is not used?
if so then why VIRT > RES?

My question, If swap is used then why it is not shown in the top output as used

GlennsPref 08-03-2009 09:18 AM

That's just for java...
Quote:

4466 aares00 24 0 4502m 2.8g 16m S 17.6 28.8 85:55.00 java
The memory is reserved.

That's all I have :)

regards Glenn

johnsfine 08-03-2009 09:31 AM

Quote:

Originally Posted by mario.almeida (Post 3629194)
VIRT = SWAP + RES.

SWAP = VIRT - RES is a strange and useless definition of the "SWAP" column used in the top program. It is not related to the actual amount of swap space used.

Quote:

checked with the output of top

Swap: 8385920k total, 0k used, 8385920k free, 2423716k cached
That swap line is the actual swap info. It is not related to the SWAP column (which by default is not displayed).

That misleading formula is only for the SWAP column of top, not for the swap line of top nor for any meaningful use of the word "swap".

Quote:

Originally Posted by mario.almeida (Post 3629515)
You mean swap is not used?

Correct. Where it says on the swap line "0k used" it means exactly what it seems to mean (unlike many of the other numbers you see there).

Quote:

then why VIRT > RES?
VIRT includes a whole lot of things that are neither RES not accurately swap.

Quote:

If swap is used then why it is not shown in the top output as used
It is not being used. The 0k for swap is correct and means what you think it means. The VIRT for each process is correct, but may not mean what you think it means. The RES for each process is also correct and doesn't mean what you think it means. The "SWAP" for each process (if you enable that column) is a useless value (VIRT-RES) and doesn't mean anything (because VIRT-RES has no useful meaning).

mario.almeida 08-03-2009 11:51 AM

Quote:

Originally Posted by johnsfine (Post 3629603)
SWAP = VIRT - RES is a strange and useless definition of the "SWAP" column used in the top program. It is not related to the actual amount of swap space used.



That swap line is the actual swap info. It is not related to the SWAP column (which by default is not displayed).

That misleading formula is only for the SWAP column of top, not for the swap line of top nor for any meaningful use of the word "swap".



Correct. Where it says on the swap line "0k used" it means exactly what it seems to mean (unlike many of the other numbers you see there).



VIRT includes a whole lot of things that are neither RES not accurately swap.



It is not being used. The 0k for swap is correct and means what you think it means. The VIRT for each process is correct, but may not mean what you think it means. The RES for each process is also correct and doesn't mean what you think it means. The "SWAP" for each process (if you enable that column) is a useless value (VIRT-RES) and doesn't mean anything (because VIRT-RES has no useful meaning).

Thanks for the info,

After posting to your early reply when through this post and got the answer

http://www.linuxquestions.org/questi...-usage-711425/


All times are GMT -5. The time now is 04:00 AM.