» » Optimize the virtual memory area (swap)

Optimize the virtual memory area (swap)

Section: System | Actuality: Linux Mint 19.1 Tessa
Optimize the virtual memory area (swap)
Around the issue of creating swap is not the first year of heated discussions. Let's abstract from it and we will consider that the area of reserve memory after all is necessary, and people often use not the swap file, namely the partition.
As a rule, the size of the swap area is equal to the amount of RAM, but it is relevant only for machines with 2-8 GB of RAM. I usually do twice as much RAM as I have. If you have 16 or more gigabytes of RAM, it is unlikely that you will want to cut off so much free space, and you are sure to limit the creation of a swap size of 2-4 GB. And if you have less than 1 GB of RAM, then... I'm sorry: swap will not help.
By default, Linux starts to access swap if the RAM is 40% or more full. The speed of reading data from the hard disk (namely, there is an area of backup memory) is much lower than the speed of access to RAM, and therefore the system begins to slow down. And to score less than half of the same 4 GB of RAM is very simple - just run any modern browser.
Optimize the virtual memory area (swap)
The free command will help you check if the system has accessed swap
Optimize the virtual memory area (swap)
Let's change the percentage that is the "trigger" to refer to the swap.
First, let's check if our Linux Mint really uses virtual memory, is when operational is filled with exactly 40 percent:
cat /proc/sys/vm/swappiness
Optimize the virtual memory area (swap)
If the system displays "60" - so it is (100-40=60).
Then we are free to correct the number. I usually change the value so that my system accesses swap only after cluttering 90 percent or more of RAM:
sudo sysctl -w vm.swappiness=10
Now we can check the value in /proc/sys/vm/swappiness again if we want to verify the effectiveness of the previous command:
cat /proc/sys/vm/swappiness
Optimize the virtual memory area (swap)
The terminal shows " 10 " - this means that swap is activated after filling 90% of RAM (100-90=10).
However, I cannot advise anything about the optimal value in your particular case. I advise you only to experiment with different numbers to achieve a perfect balance. They are usually in the range of 10 to 30.
May the Force be with you,
Good Luck!!!

Print version

    Your working environment Other polls