I have 5.4 GB of 6.8 GB usage of RAM and 927.5 MB of 976 MB of Swap memory.
Even though i have 1.4 GB of RAM usage Ubuntu is using up all of the swap memory. Although the swap memory is using my SSD space it will be much slower than my RAM. Shouldn't it use up all the RAM and then occupy Swap ?
3 Answers
You can use sysctl vm.swappiness=10
to reduce the drastic swap rate. And you can switch on or off with swapoff -a
and swapon -a
with root privileges.
If you want to use hibernation, suitable spot for swap space is twice the size of RAM size.
-
How should I increase it to 4GB and why should I do so. Is it healthy for my system ?? Dec 22, 2019 at 11:42
-
1Swap Space is only useful if you have low amount of RAM. And only if you leave your pc in hibernation, you need twice the size of RAM as a suitable spot. This tutorial is for Manjaro but works fine on Ubuntu: classicforum.manjaro.org/index.php?topic=30763.0 Dec 22, 2019 at 12:28
Edit /etc/sysctl.conf
as root. Change or add this line to the file:
vm.swappiness = 5
One way to do this is by using sudo nano /etc/sysctl.conf
in a terminal window.
Reboot the system after saving the edited file.
This will instruct the system to use swap memory only when RAM is used almost completely.
976 MB of swap memory is not enough. It should be increased to at least 4 GB.
-
How should I increase it to 4GB and why should I do so. Is it healthy for my system ?? Dec 22, 2019 at 11:43
-
1Everything you need is here: askubuntu.com/questions/178712/how-to-increase-swap-space Dec 22, 2019 at 12:02
Ubuntu will use RAM. When this becomes limiting, currently unused segments of memory are moved to swap space. That memory will be retrieved from there only when needed again in active RAM. If not needed, it will just be kept in swap even if in the mean time more RAM is becoming available.
You did not provide any indication of the use of your machine that resulted in the memory state you show. The memory state of a linux machine is dependent on how the system has run and what the memory requirements have been thus far. For sure, a freshly booted machine with 6 GB RAM will not be using swap. Swap use will eventually grow depending on the memory needed by your computer use.
I would merely thrust your linux system, which employs SWAP to maximize efficient use of real RAM. Still, you may want to decrease the tendency to use swap by changing the swappiness value. This will decrease the tendency to swap away active applications and give you a subjective impression of more responsiveness, although some processes may be more limited because of less RAM.
swappiness
which allows some configuration of when swap is used.