Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to reserve a specific amount of memory for a specific service/process?

I would like to guarantee that OpenSSH always has enough memory available to it that it can accept a new SSH connection in case the server's memory fills up.


share|improve this question
Oh, don't worry. If memory fills up the OOM killer will "deal" with it for which point you have two problems. – dmckee Feb 9 '10 at 0:47

Generally speaking you don't "reserve" memory on *nix systems - you ensure that there is enough physical RAM + Swap space to handle what your server is doing, and you let the VM subsystem handle it from there (though as dmckee pointed out in Linux you have the "helpful" OOM killer which will kill the "biggest memory user" when you run out of RAM -- the logic of the aforementioned "helpful" subsystem is suspect at best).

You should try to figure out why your system is running out of memory (if that's actually the problem): If you fix the underlying problem you won't need to reserve RAM.

share|improve this answer
This problem has happened several times, and it has never been freed up. We had to restart the VPS everytime it happened as we could not SSH in. I am trying to figure out what is causing it right now. I started this post earlier: – mhost Feb 9 '10 at 3:07
@helphost: Generally the OOM killer does it's job very reliably. If the system is getting exceedingly slow but not stopped, then you have too much swap in place and the thrashing is taking circa 100% of the available CPU. If it is just freezing in may not be memory related at all. – dmckee Feb 9 '10 at 4:05
@dmckee My bias against the OOM killer (& Linux memory management in general) summarized: – voretaq7 Feb 9 '10 at 4:11
That bias taken into account however, @dmckee is on the money - the OOM killer will make sure you have free memory (You just might not like what is kills to get you to that point :-) – voretaq7 Feb 9 '10 at 4:12
@helphost: Ah... That is another situation entirely...good question. You might want to edit question text to reflect it, though. – dmckee Feb 10 '10 at 0:01

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.