Been going through this topic - https://askubuntu.com/questions/157793/why-is-swap-being-used-even-though-i-have-plenty-of-free-ram.
Turned down swappiness to 10 and then to 0 but my installation is never able to reach out into 70%+ of RAM before turning to the swap area. So I am wrestling my lunix system with the help of that script from the link above, but still no joy. I am getting:
kellogs@kellogs-K52Jc ~/workspace/xgate_git/tigase-server $ sudo unswap.sh
Free memory: 1525024 kB (1489 MB)
Used swap: 938196 kB (916 MB)
Freeing swap...
swapoff: /dev/sda4: swapoff failed: Cannot allocate memory
and even:
kellogs-K52Jc tigase-server # unswap.sh
Free memory: 1212956 kB (1184 MB)
Used swap: 478516 kB (467 MB)
Freeing swap...
swapoff: /dev/sda4: swapoff failed: Cannot allocate memory
It must be something keeping the OS from using the 30% remainder of RAM. But what ?
EDIT:
Original: vm.overcommit_memory = 0 vm.overcommit_ratio = 50
Set to vm.overcommit_memory = 2 vm.overcommit_ratio = 100
And RAM usage would stall at about 50%; After this programs would not launch any longer and complain about memory shortage. Swap remained at 0% usage.
Set to: vm.overcommit_memory = 1 vm.overcommit_ratio = 100
Managed to go to about 83% RAM and 22% swap usage. Then I have called that script for emptying swap-into-RAM and hell broke loose. libflash crashing, the rest of programs unresponsive and having gone into broken pipes and stuff like that.
vm.overcommit_ratio
to less than 100. @kellogs, what is the result ofsysctl -a | grep vm.overcommit
? – phemmer Feb 14 '14 at 04:39vm.overcommit_memory=0
is the default and usually sensible option. I doubt it's the problem. Setting to1
disables the restrictions entirely. You definitely don't want to set it to2
without thorough research on what to set the ratio at. The reason it went nuts when you set it to1
is that the kernel no longer protected you from using all your ram, and that's exactly what happened, 100% memory usage. – phemmer Feb 14 '14 at 13:27unswap.sh
script you're using? What makes you think you can't go over 30% of RAM: what are the figures you're comparing? Why are you fiddling with overcommit (if you switch to unrestrained overcommitting, programs crashes when the system runs out of memory is to be expected)? – Gilles 'SO- stop being evil' Feb 14 '14 at 15:15