3

While running 5-6 programs at the same time (Browser, Virtual Machines, Terminal, Text Editor, File Explorer), some of them from time to time (let's say every 15 minutes) are inactive/idle (not interacting with the user, not doing calculations etc.). Is it possible to:

  • have the inactive programs memory data automatically transferred from RAM to Swap, and
  • instant (or some seconds delay maybe) "activisation" (memory data from Swap to RAM) when the user starts interacting with a software (or it becomes active/is brought in foreground).

Keeping in mind that Swap memory is slower than RAM but still fast enough to not freeze the UI, shifting "RAM attention" would be very useful in many computers, for different programs or even inside a single program (Imagine a-lot-of-Ram-consuming-browser Swap-ping the memory data of background opened tabs and keeping in Ram only the active tab).

Is this something that can be done by any means nowday or maybe is it partially already like this?

1 Answers1

3

Automatically:

  • Yes, and that's what you have now: the Linux Memory manager swaps out unused programs to disk and swaps in programs that are used.
  • However, the kernel is optimised for a server, not a desktop, so if you want the kernel to swap earlier / later, you have to adapt your swap and swappiness to your use case.

Manually:

  • That's possible by using cgroups: you can decide which program is getting or not getting any RAM and which has CPU priority over another.
  • The simple methods are:
    • to close any programs that you don't use / need right now.
    • buy more RAM if you need to have all of them running as the kernel does not care about foreground or background applications and will gladly swap out LibreOffice if a large FTP transfer is running in the background.

¯\_(ツ)_/¯

Fabby
  • 34,259