Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What happens when linux OS is out of RAM and no swap is available?

share|improve this question

migrated from stackoverflow.com Jan 16 '13 at 1:42

This question came from our site for professional and enthusiast programmers.

It 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 Jan 16 '13 at 1:27

4 Answers 4

up vote 9 down vote accepted

Typically the OOM killer steps in and starts killing processes.

For a more comprehensive discussion, please refer to David Schwartz's answer.

share|improve this answer
-1 That's what it does when it's out of virtual memory, not when it's out of RAM. When it's out of RAM, it just discards clean pages. –  David Schwartz Jan 16 '13 at 2:32
@DavidSchwartz: True. I guess this is the logical extent. –  Oliver Charlesworth Jan 16 '13 at 2:34
You've given the canonical wrong answer -- the one that leads people to doing completely the wrong thing when they administer servers. Running out of RAM is 100% normal and causes no serious consequences, even if there's no swap. –  David Schwartz Jan 16 '13 at 2:37
@DavidSchwartz: Whether mine is misleading or not, your answer is more comprehensive. So I'm deleting mine in favour of yours... –  Oliver Charlesworth Jan 16 '13 at 2:43
@DavidSchwartz: Oh, apparently I can't because it's been accepted. –  Oliver Charlesworth Jan 16 '13 at 2:43

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.

share|improve this answer
+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 Feb 12 '14 at 11:40
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 Mar 6 at 13:02
@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 Mar 6 at 17:54

I have experimented with my laptop to disable the swap partition and use only my 4GB of RAM.

More precisely I disabled the swap with swapoff -a and commented the entry in the /etc/fstab file related to the swap partition. Then I tried to use the PC as usual for my development activities.

When the RAM usage go up and the free space get low something strange happen. I thought that the process were simply killed or they would simply crash but what happen is the following:

The PC is very slow and sometime even the mouse cursor doesn't move. The strange thing is that even if no swap partition are set up the disk led is steady on. The only option I have in this case is to press Ctrl+Alt+Backspace and wait until Xorg is rebooted.

I'm wondering why the system does not simply kill process and why does it look for a swap partition on the disk even if it's not present?

share|improve this answer
That's not really an answer, but more an extension to the question. However, since I have experienced the same, I would be happy to hear why this strange behaviour occurs. –  Konstantin Nov 27 '14 at 0:35

See here for a more detailed explanation, but basically, it kills random processes to save memory.

share|improve this answer
Not so random, actually. It has a scoring mechanism. –  Chris Jan 16 '13 at 1:30
Did you read your link? That's what Linux does when it's out of virtual memory. The question was what Linux does when it's out of RAM. –  David Schwartz Jan 16 '13 at 2:32
@DavidSchwartz did you read the question? It said what linux does when it's out of RAM and swap. The very definition of virtual memory is RAM + swap. –  hd1 Jan 16 '13 at 7:08
@hd1: No, because a system can be out of RAM, have no swap, and can nevertheless produce huge amounts of additional virtual memory -- for example, by a successful call to fork or a large, read-only mmap of a file. Virtual memory can be overcommitted, RAM cannot be. Read my answer. –  David Schwartz Jan 16 '13 at 7:11
@hd1: If you have a counterargument, feel free to share it. But I'm already well aware that I might be wrong and my knowledge is incomplete. You're only helping if you tell me how I am wrong. –  David Schwartz Jan 16 '13 at 7:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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