The Linux kernel cannot gracefully handle out-of-memory situations.

On the Linux kernel developers' mailing list. raised the issue of handling memory exhaustion in Linux:

There is a known problem that has plagued many users for years and can be reproduced in under a few minutes on the latest version of the Linux kernel 5.2.6. All kernel parameters are set to default values.

Steps:

  • Boot with the 'mem=4G' parameter.
  • Disable swap support (sudo swapoff -a).
  • Launch any web browser, such as Chrome/Chromium or Firefox.
  • Start opening tabs with websites and watch the amount of free memory decrease.

As soon as a situation arises where a new tab requires more RAM than is available, the system nearly completely freezes. You might even struggle to move the mouse cursor. The hard drive indicator will blink non-stop (I’m not sure why). You won’t be able to launch new applications or close the ones currently running.

This little crisis can last for minutes or longer. I suspect the system shouldn't behave this way. I think something should be done to prevent such 'freezes'.

I’m almost certain that it’s possible to change some sysctl parameters to avoid such situations, but something tells me this could be done by default for everyone, as non-technical users faced with this issue will simply abandon Linux rather than look for solutions on Google.

In comments on Reddit, some users suggest enabling swap, but that doesn’t solve the problem, it merely postpones it and often aggravates it. A possible solution in the future might involve the recently introduced in-kernel 4.20 and improved in-kernel 5.2 PSI (Pressure Stall Information) subsystem, which allows for analyzing wait times for various resources (CPU, memory, I/O). This subsystem enables early tracking of memory shortages, identifying the source of problems, and terminating unimportant applications without leading to noticeable user effects.

Source: opennet.ru

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster