Swap usage by top and free command doesn't match


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Swap usage by top and free command doesn't match
# 1  
Old 02-08-2012
Swap usage by top and free command doesn't match

Its rather confusing, the output of top command is below:

Quote:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ SWAP COMMAND
25303 mysql 15 0 2968m 708m 4948 S 38.2 9.0 225:26.20 2.2g mysqld

The "swap" field of top is described by the manpage as: "The swapped out portion of a task's total virtual memory image."

But the output of free command suggests something else and it does tally with the output of swapon command:

Quote:
[root@server ~]# free
total used free shared buffers cached
Mem: 8046000 7476800 569200 0 296012 5291468
-/+ buffers/cache: 1889320 6156680
Swap: 4192956 61320 4131636

[root@server ~]# swapon -s
Filename Type Size Used Priority
/dev/cciss/c0d0p2 partition 4192956 61320 -1


So why is this discrepancy? How would i determine which process is using how much swap?

---------- Post updated at 05:40 PM ---------- Previous update was at 03:05 AM ----------

Any help will be highly appreciated.. Smilie
# 2  
Old 02-08-2012
What is the OS you are using?
If it's a Linux operating system, you can easily find the swap memory used by a process with the following:
Code:
grep "VmSwap" /proc/PID_OF_PROCESS/status

The output is in bytes. Smilie
# 3  
Old 02-08-2012
Yes it is RHEL. But why is the discrepancy between the top and free command output?
# 4  
Old 02-08-2012
This entirely depends on the perspective the program is looking from. Not only free top, people found discrepancies among the outputs of sar -r, vmstat, ps aux.

But, as far as my knowledge goes, free command shows output using /proc/meminfo file. That's a direct output from kernel and ought to be more correct one.
This User Gave Thanks to admin_xor For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Need help on top and free command.

Hi, from below output.How to read or relate one marked in bold. $ free -m total used free shared buffers cached Mem: 129176 92753 36423 0 2268 39973 -/+ buffers/cache: 50511 78664 Swap: 31996 ... (1 Reply)
Discussion started by: manoj.solaris
1 Replies

2. Solaris

Physical and Free mem on TOP command

Hi, When I run the free command on solaris, I get the following: "Memory: 60G phys mem, 69G free mem" Q: how cna the free mem be higher then the physical mem?:confused: Amit (3 Replies)
Discussion started by: amitlib
3 Replies

3. UNIX for Dummies Questions & Answers

[Query] Confusion of the Swap when using 'free -m' command

Hi All, I have just installed my first Linux server ( Ubuntu 11.10 ). I am sure I didn't allocate /swap , and double check by 'df -h', yes really no /swap but when I use 'free -m' , returned a "Swap" line as below. total used free shared buffers cached Mem: ... (3 Replies)
Discussion started by: joaming
3 Replies

4. Linux

Unkown memory usage, top doesn't know

Hi, Yersterday I started monitoring my homeserver memory consumition due some errors found in the system (network hangs). I've detected almost all the memory used (~10 MB free from 1GB). First I thought it was because of the MySQL configuration, so I monitored it with top and found it wasn't... (6 Replies)
Discussion started by: nefeli
6 Replies

5. Solaris

Memory usage, free and used, using sar, top and vmstat in Solaris zone/container

Hi all, I have a server running an Oracle database that is part of a Solaris M5000 container. Presumably this is referred to as a zone within a cluster, not sure if I get the terminology right. Anyway, a third-party manages the zone and unfortunately is not "helpful/friendly" to assist me on... (1 Reply)
Discussion started by: newbie_01
1 Replies

6. UNIX for Dummies Questions & Answers

Query related to swap information shown by top command

Hi I have checked the output of top command in which there is a difference shown between the swap of top command for a process with total swap memory usage of the top command. Swap usage of process is higher than the total swap memory usage. top - 18:28:21 up 7:13, 5 users, load... (2 Replies)
Discussion started by: gagan2914
2 Replies

7. Solaris

Free memory in top and prstat command

Hi Export, i execute 'top' command to show the free memory in Solaris host, but the read is much lower than the RSS value shown in prstat command. Which one can reflect the real status and it is possible the difference caused by any patch of OS? Top command (only 883 memory is free)... (3 Replies)
Discussion started by: eiga
3 Replies

8. UNIX for Dummies Questions & Answers

Unix Top Command and sorting by CPU Usage

Ok, so I am using the Top command on my linux VPS to try and see the processes using the most CPU %. I hit the P to sort by CPU % but it wants to sort them from lowest to highest (ascending). My Telnet-SSH screen is only about 60 rows high so the processes with the highest CPU % usage are at the... (6 Replies)
Discussion started by: davemehta
6 Replies

9. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

10. UNIX for Advanced & Expert Users

unix top command (memory usage)

in unix when i use top i get an output like this: load averages: 0.64, 0.57, 0.53 14:04:42 347 processes: 1 running, 1 waiting, 169 sleeping, 172 idle, 4 stopped CPU states: 16.4% user, 2.8% nice, 7.6%... (2 Replies)
Discussion started by: gfhgfnhhn
2 Replies
Login or Register to Ask a Question