Swap usage by top and free command doesn't match

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:

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.. :slight_smile:

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. :b:

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