Another option:
#!/bin/bash # Get current swap usage for all running processes # Erik Ljungstrom 27/05/2011 SUM=0 OVERALL=0 for DIR in `find /proc/ -maxdepth 1 -type d | egrep "^/proc/[0-9]"` ; do PID=`echo $DIR | cut -d / -f 3` PROGNAME=`ps -p $PID -o comm --no-headers` for SWAP in `grep Swap $DIR/smaps 2>/dev/null| awk '{ print $2 }'` do let SUM=$SUM+$SWAP done echo "PID=$PID - Swap used: $SUM - ($PROGNAME )" let OVERALL=$OVERALL+$SUM SUM=0 done echo "Overall swap used: $OVERALL"
Found here http://northernmost.org/blog/find-out-what-is-using-your-swap/
I want to answer where did the problem with swap-space come from. This could be this bug http://osdir.com/ml/ubuntu-bugs/2016-03/msg00360.html , but I have version 14.04, so this is not my case.
On my system so
xuser@mh:~$ df -h Файл.система Размер Использовано Дост Использовано% Cмонтировано в udev 3,9G 4,0K 3,9G 1% /dev tmpfs 799M 1,3M 798M 1% /run /dev/sda2 54G 12G 39G 23% / none 4,0K 0 4,0K 0% /sys/fs/cgroup tmpfs 1,0G 183M 842M 18% /tmp none 5,0M 0 5,0M 0% /run/lock none 3,9G 1,4M 3,9G 1% /run/shm none 100M 20K 100M 1% /run/user tmpfs 1,5G 291M 1,2G 20% /home/xuser/.cache tmpfs 512M 199M 314M 39% /home/xuser/.mozilla tmpfs 5,0G 0 5,0G 0% /home/xuser/torTmp /dev/sdb1 230G 108G 111G 50% /media/xuser/9bd1fae0-bcb9-4677-9f1a-28ac7079dccc xuser@mh:~$
I started the virtual machine and forgot to clear the folder
/home/xuser/torTmp
and I have it designed for torrents and a virtual machine image.
swapoff -a
wrote an error saying that it could not allocate memory.
I later realized that I had to look at what was happening in my memory system. The end of the story :).