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?