I have a server that is not a virtual machine, and has plenty of RAM (32GB) and its using less than 6, but I constantly get this error when running some programs.

root@DAL1-727]# free -m
bash: fork: Cannot allocate memory

if I then kill something benign (like an extra bash session I had open in screen) I can get it to let me do things:

[root@DAL1-727]# free -m
             total       used       free     shared    buffers     cached
Mem:         32067       5015      27052          0         55       1293
-/+ buffers/cache:       3666      28401
Swap:        16095          0      16095

I'm opening a lot of files and apache is probably the cause. I've tried setting my file limits higher, but this still happens.

ulimit -n 1048576

output of /etc/security/limits.conf

soft nproc 65535
hard nproc 65535
soft nofile 65535
hard nofile 65535
apache hard nofile 64000

What else could this be?

  • Try command sync before free -m, it will drop buffers of disk from memory. Maybe this is a catch, at least we can find out if its a problem with memory or something else. – Mateusz Pacek Sep 10 '15 at 8:09
  • Is this server running 32 or 64-bit kernel? I'm not sure whether a 32-bit kernel would explain these symptoms (and it's a while since I dealt with one). – Paul Haldane Sep 10 '15 at 17:16
  • It is running a 32-bit kernel I will try sync before free -m, but I really don't think it's related to a lack of memory on the box, more likely how it's allocated. – Tedd Johnson Sep 11 '15 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.