Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 859  / 3 Years ago, sat, november 20, 2021, 9:58:04

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 the rest of the system (not necessarily the offending app) is 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. I can't meaningfully interact with the rest of the system.




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. The most crucial aspect is that I'm unable to interact with the rest of the system.


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?




Test update


After (not so quickly) doing the quick test suggested in the comments where I doubled the size of the swapfile I can conclude that it makes all the difference in the world. The system remained responsive throughout during the same load. I can only conclude that an adaptive swap size would alleviate the described problem.


$ free -h
total used free shared buff/cache available
Mem: 3.7Gi 3.1Gi 129Mi 374Mi 566Mi 105Mi
Swap: 4.0Gi 3.0Gi 988Mi

$ sysctl vm.swappiness
vm.swappiness = 60

$ swapon -s
Filename Type Size Used Priority
/swapfile_4G.img file 4194300 3180664 20



A note on hardware


One of the selling points of Ubuntu (among others) is to get continued support and increase the life-span of older hardware, which includes machines with less than average total memory. Not absurdly little memory, as demonstrated by the fact that other OSes can make do just fine, just less than average. Many of these machines are non-upgradable.


4 GB RAM works fine for most use cases. In Ubuntu, in Windows, in macOS. What only seems to work fine in Windows and macOS, however, is when you use up all allocated swap space.


In short, the same instant that the solution to making Ubuntu run decently becomes "buy new hardware" the whole point of running it becomes moot for all these machines. Upgrading the hardware is out of scope for this question.


The requirements for the standard edition of Ubuntu is 4 GB of memory.


More From » ram

 Answers
3

As was mentioned in a comment by @Terrance Swapspace is a solution to this problem.


apt install swapspace

Now all you need to stay in control of your system is some free storage. Tested and works.


[#1460] Saturday, November 20, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tersle

Total Points: 342
Total Questions: 109
Total Answers: 99

Location: Kazakhstan
Member since Mon, Sep 26, 2022
2 Years ago
tersle questions
Sat, Oct 23, 21, 00:33, 3 Years ago
Sun, Apr 17, 22, 23:01, 2 Years ago
Thu, May 11, 23, 22:57, 1 Year ago
Thu, Sep 22, 22, 22:14, 2 Years ago
;