LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 08-03-2009, 02:16 AM   #1
mario.almeida
Member
 
Registered: May 2008
Location: India
Distribution: Ubuntu 10.04, CentOS
Posts: 177

Rep: Reputation: 27
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
 
Old 08-03-2009, 02:34 AM   #2
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: Mageia Studio-13.37 Kubuntu.
Posts: 3,325
Blog Entries: 33

Rep: Reputation: 199Reputation: 199
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
 
Old 08-03-2009, 08:06 AM   #3
mario.almeida
Member
 
Registered: May 2008
Location: India
Distribution: Ubuntu 10.04, CentOS
Posts: 177

Original Poster
Rep: Reputation: 27
Quote:
Originally Posted by GlennsPref View Post
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
 
Old 08-03-2009, 09:18 AM   #4
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: Mageia Studio-13.37 Kubuntu.
Posts: 3,325
Blog Entries: 33

Rep: Reputation: 199Reputation: 199
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
 
Old 08-03-2009, 09:31 AM   #5
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,057

Rep: Reputation: 1104Reputation: 1104Reputation: 1104Reputation: 1104Reputation: 1104Reputation: 1104Reputation: 1104Reputation: 1104Reputation: 1104
Quote:
Originally Posted by mario.almeida View Post
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 View Post
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).

Last edited by johnsfine; 08-03-2009 at 10:17 AM.
 
Old 08-03-2009, 11:51 AM   #6
mario.almeida
Member
 
Registered: May 2008
Location: India
Distribution: Ubuntu 10.04, CentOS
Posts: 177

Original Poster
Rep: Reputation: 27
Quote:
Originally Posted by johnsfine View Post
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/

Last edited by mario.almeida; 08-03-2009 at 11:53 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple bash calculation Hiperi0n Programming 12 11-14-2008 08:10 AM
Calculation aid script! assasukasse Programming 24 09-15-2007 12:07 PM
disk space calculation tostay2003 Linux - General 3 06-22-2007 12:53 PM
do a calculation for block sice procfs Programming 12 07-12-2006 02:27 AM
c math calculation alaios Programming 3 06-01-2004 01:46 AM


All times are GMT -5. The time now is 06:14 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration