How to configure how much RAM usage should to start swapping on Ubuntu

The answer to your question how, is "no". Linux is extremely good at memory management. You could never hope to compete with it. And you wouldn't want to unswap just because you had free RAM. Because Linux knows what parts of the memory is most useful. In other words; you'd reduce performance drastically by manually moving unused memory from the harddisk and into RAM.


See the section titled "What is swappiness and how do I change it?" on this page:

https://help.ubuntu.com/community/SwapFaq

But, I also agree with Jo-Erlend Schinstad. If there is no urgent need to change the default behavior, it is best to leave it alone. However, I see that the article itself recommends a value of 10, while the default is 60. So, changing to the recommended value of 10 should take you the way you want to go (less swapping).

Also, part of your original question is, how to empty swap. swap is emptied every time you reboot.