ram – Automatically manage swap / memory

When filling up all memory and swap my experience the most recent years has been that:

  • Windows and macOS go “oh, let’s fix that for you” and then presumably increase the swap size. Opening e.g. 30 YouTube tabs slows things down for a while, but I can generally still use the cursor if I want to abort the process, and after that it’s pretty much as responsive as always.

  • Ubuntu (21.04) goes “sorry, you can’t interact with the computer for the next ten to thirty minutes”. On the same hardware and the same browser, I can open 30 YouTube tabs and watch the whole system lock up. All memory and swap is used up, and the cursor is not just slow but locked in place.

The difference seems to be that Ubuntu never resolves the situation, keeps its swap size constant and consequently keeps locking up every five seconds, forever. Until, that is, catastrophic failure occurs and Firefox disappears without a trace — something that virtually never happens in other OSes.

I don’t know, but I get the impression this would not be an issue if the swap size were increased based on demand. How is that accomplished? Is there better memory management to be had somehow?