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
    Sounds like you want to do manual memory management, which is an extensive topic, not suitable for one question. Also, the linux kernel obviously already does it. – mikewhatever Oct 3 '18 at 17:40
  • As you've never accepted an answer on this site before: If one of the answers solved your problem, don't forget to click the grey at the left of its text, which means Yes, this answer is the most useful of all! ;-) – Fabby Oct 8 '18 at 15:05


  • 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.


  • 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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.