23
9
What happens when linux OS is out of RAM and no swap is available?
23
9
What happens when linux OS is out of RAM and no swap is available?
36
When the operating system is out of RAM and has no swap, it discards clean pages. It cannot discard dirty pages because it would have to write them somewhere first. This causes thrashing and poor performance if there is insufficient RAM to hold the working set. That's one of the main reasons you really want swap -- so the operating system can make a better decision about what pages to evict.
With no swap, the system will run out of virtual memory (strictly speaking, RAM+swap) as soon as it has no more clean pages to evict. Then it will have to kill processes.
Running out of RAM is completely normal. It's just a negative spin on using RAM. Not running out of RAM could equally well be described as "wasting RAM". Once all RAM is in use, the operating system makes intelligent decisions about what to keep in RAM and what not to. Without any swap, it has fewer choices.
With or without swap, when evicting pages isn't sufficient, the operating system will start by refusing to permit operations that require memory (such as mmap
and fork
) to succeed. However, sometimes that's not enough and processes have to be killed.
A related query. Do you know what happens if I try to hibernate a Linux machine and there isn't enough swap space to store the transient data? Does it stop hibernating? – Prahlad Yeri – 2015-03-06T13:02:26.963
1@PrahladYeri That's correct. If you don't have a suspend partition and there isn't enough free swap to hold the contents of RAM, you cannot hibernate. – David Schwartz – 2015-03-06T17:54:22.173
https://unix.stackexchange.com/q/153585 – Sampo Sarrala - codidact.org – 2017-08-23T14:42:45.973
4+1 "Running out of RAM is completely normal. It's just a negative spin on using RAM. Not running out of RAM could equally well be described as "wasting RAM"." – TheTurkey – 2014-02-12T11:40:30.483
15It would be bad. Try to imagine all life as you know it stopping instantaneously and every molecule in your body exploding at the speed of light. Total protonic reversal. – David – 2013-01-16T01:27:54.627