Under Linux, how do I find out which process is using the swap space more?
相关问题
- What uses more memory in c++? An 2 ints or 2 funct
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- Memory for python.exe on Windows 7 python 32 - Num
- Error building gcc 4.8.3 from source: libstdc++.so
I did notice this thread is rather old, but if you happen to stumble upon it, as I just did, another answer is: use smem.
Here is a link which tells you both how to install it and how to use it:
http://www.cyberciti.biz/faq/linux-which-process-is-using-swap/
It's not entirely clear if you mean you want to find the process who has most pages swapped out or process who caused most pages to be swapped out.
For the first you may run
top
and order by swap (press 'Op'), for the latter you can runvmstat
and look for non-zero entries for 'so'.I adapted a different script on the web to this long one-liner:
Which I then throw into a cronjob and redirect output to a logfile. The information here is the same as accumulating the
Swap:
entries in the smaps file, but if you want to be sure, you can use:The output of this version is in two columns: pid, swap amount. In the above version, the
tr
strips the non-numeric components. In both cases, the output is sorted numerically by pid.Another script variant avoiding the loop in shell:
Standard usage is
script.sh
to get the usage per program with random order (down to howawk
stores its hashes) orscript.sh 1
to sort the output by pid.I hope I've commented the code enough to tell what it does.
I don't know of any direct answer as how to find exactly what process is using the swap space, however, this link may be helpful. Another good one is over here
Also, use a good tool like htop to see which processes are using a lot of memory and how much swap overall is being used.
On MacOSX, you run top command as well but need to type "o" then "vsize" then ENTER.