Reputation: 81
I am suspecting some swap actitivies in my MySQL box. I ran the "top" utility it gave me only 51MB of swap took place.
However, when I enabled the "Swap" column in top utility, it showed that there were actually 12g of swap used by mysqld.
Can you tell me which is the accurate information? Is there any swap taking place?
Upvotes: 2
Views: 596
Reputation: 562558
Edit: From what I've read, SWAP column in the output of top is really just VIRT - RES
. It's an assumption that part of the process has been swapped out. It's difficult or impossible to get an accurate measure of how much swap a given process is using.
If you're on Linux or one of the UNIX flavors that support /proc
, you can use this to get the actual usage:
cat /proc/18810/status
(Where 18810 is the PID of your mysqld process.)
It'll show you a bunch of fields for actual memory usage. Here's an except from the mysqld process in my development VM:
VmPeak: 3258116 kB
VmSize: 3258116 kB
VmLck: 1416344 kB
VmHWM: 1180788 kB
VmRSS: 1180780 kB
VmData: 3189940 kB
VmStk: 88 kB
VmExe: 11608 kB
VmLib: 7312 kB
VmPTE: 2540 kB
VmSwap: 0 kB
The VmSwap of 0 indicates that it is not currently using any swap.
See http://man7.org/linux/man-pages/man5/proc.5.html or just man 5 proc
for information on the other fields. The manual says in part:
- VmSwap: Swapped-out virtual memory size by anonymous private pages; shmem swap usage is not included (since Linux 2.6.34).
Re your comment:
Apparently you use a version of Linux too old to include the VmSwap field in per-process status.
You can read /proc/meminfo and find out the total swap space in use on the server, but this doesn't tell you per process.
You can also run vmstat to watch for swap activity. If the "si" and "so" fields are zero, you're okay.
Upvotes: 2