"Cannot fork" error messages

32,120

Solution 1

The problem ended up being this one:

https://bugs.launchpad.net/ubuntu/+source/php5/+bug/877894

fuser process started by cron job forking uncontrollably

Solution 2

You must have set a limit for the maximum number of processes in /etc/security/limits.conf or perhaps some default is set in Ubuntu.

I had that set to 350 processes to prevent accidential fork-bombs. What drove me crazy - when my processes couldn't fork anymore, the number of processes I ran at the time was far from the limit.

Turns out the reason for that was, that not processes were counted, but kernel level threads.

ps -efL | grep ^$USER | wc -l 

indeed showed that I was close to the limit. The many tabs/windows I had open in chromium alone could amount to over 100 such threads - no wonder I hit that limit easily.

Share:
32,120

Related videos on Youtube

Martin Konecny
Author by

Martin Konecny

Software-developer for Lucova. Some of my favourite answers: http://stackoverflow.com/a/34823421 http://stackoverflow.com/a/30362874 http://stackoverflow.com/a/24007536 http://stackoverflow.com/a/16641452

Updated on September 18, 2022

Comments

  • Martin Konecny
    Martin Konecny almost 2 years

    This happens with many different programs from the terminal. Usually accompanied with some error message about not being able to allocate memory.

    When I try "free -m" this is the output:

    martin@martin-ThinkPad-T410:~$ free -m
                 total       used       free     shared    buffers     cached
    Mem:          3823       3079        744          0         99       1159
    -/+ buffers/cache:       1820       2003
    Swap:         3953         60       3893
    

    Why is my swap usage so low? Is this related?

    • Martin Konecny
      Martin Konecny over 12 years
      This was driving me crazy, especially since no one else had this problem. I've since left to Debian Squeeze, and the problem has disappeared, so it wasn't a hardware issue.