Its rather confusing, the output of top command is below:
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:
[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..
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:
grep "VmSwap" /proc/PID_OF_PROCESS/status
The output is in bytes.
Yes it is RHEL. But why is the discrepancy between the top and free command output?
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.
1 Like