Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

I am frequently getting:

fork: Cannot allocate memory

when running commands over ssh. I have 4 GB of RAM and usually 2 GB free. This started happening since I upgraded to Ubuntu 11.10.

I then need to repeatably run the command until it finishes successfully.

I'm connecting from my laptop to my server both from my home LAN. Some times happens even when I run apt-get.

Any idea why?

share|improve this question
I think you have to provide more details otherwise this won't be solveable. I suppose the machine you are describing is the ssh server you are connecting to? (and not the client) When this happens run free and post the output here (and what program caused the error) – lumbric Dec 21 '11 at 15:52
Are you running in a VPS ? – bodhi.zazen Dec 21 '11 at 16:14
I'm connecting from my laptop to my server both in home lan. Some times happens even when I run apt-get. I'll check free next time. – xrado Dec 21 '11 at 21:58
I am getting exactly same problem, also lots of others. See this: – BlackDivine Jan 29 '12 at 20:00
How much memory is bash using when it happens? ps -o rss,vsize,args $$ – geirha Feb 26 '12 at 21:11

Can you provide us with the output of ulimit -a ran in a session where this happens?

/etc/pam.d/sshd should involve when you open a session. This module will use /etc/security/limits.conf to apply various restrictions to your session, including regarding memory usage.

share|improve this answer

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.