Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 1595  / 3 Years ago, sat, august 14, 2021, 11:05:16

I have Ubuntu 18.04 installed on my PC which having 8GB total memory and I allowed 2GB swap space when installing Ubuntu. When in normal operation it uses about 2GB from main memory and zero of swap.



My problem is, when I'm running a memory crunching process, It will start to use swap space after exhausting all the main memory available, but when I finished memory crunching process it will keep using swap space even if the main memory available in GB's. Due to usage of swap my PC getting slow after this operation. So this will lead to restart my PC to recover from it.



Is there a way to fix this, so that I can clear swap when main memory is available? Or is it a bug?


More From » 18.04

 Answers
6

Once swap has been addressed, some swap will typically remain used even if after having run a memory consuming operation, you revert to your "normal" use of about 2 GB. After having used your memory crunching process, much of the other processes will have been swapped to the swap memory. These will be reclaimed to RAM as they are needed again by other activities. They will remain in swap as long as they are not needed. Typically, you should see that gradually swap use decreases, and the system becomes faster again.



There is a way to get more quickly back to normal. You can immediately "flush" all processes from SWAP back to main memory by turning swap off and back on. This requires the commands:



sudo swapoff -a
sudo swapon -a

[#7135] Sunday, August 15, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rowbris

Total Points: 419
Total Questions: 122
Total Answers: 101

Location: Norway
Member since Mon, May 23, 2022
2 Years ago
;