shutch190
By:
shutch190

When I log in via ssh I get a -bash fork: Cannot allocate memory. How to solve?

September 24, 2014 11.6k views

Clearly the system has run out of memory.

The problem is that the only way to solve this issue is to restart from the digital ocean terminal. As any command I type gets the same response:

-bash: fork: Cannot allocate memory

I have a 2Gb droplet and I don't want to jump to the conclusion of increasing memory.
Is there a way to ensure that I will always have enough memory to ssh and hit cli commands?
Also is there a way to find out exactly what has caused it?

1 comment
  • Have you tried adding swap to your droplet? How To Add Swap on Ubuntu 14.04 | DigitalOcean

    I would suggest rebooting your droplet, sshing in and then running (h)top. Keep an eye on the memory usage and see what process is using up all the memory.

    by Justin Ellingwood
    Swap space can be used as an "overflow" area for your system when you run out of RAM. The operating system can store data that would normally be kept in RAM on the hard drive in a specially formatted file. In this guide, we'll demonstrate how to create and use one of these files in Ubuntu 14.04.
1 Answer

This question was answered by @kamaln7:

Have you tried adding swap to your droplet? How To Add Swap on Ubuntu 14.04 | DigitalOcean

I would suggest rebooting your droplet, sshing in and then running (h)top. Keep an eye on the memory usage and see what process is using up all the memory.

You can see the comment here.

by Justin Ellingwood
Swap space can be used as an "overflow" area for your system when you run out of RAM. The operating system can store data that would normally be kept in RAM on the hard drive in a specially formatted file. In this guide, we'll demonstrate how to create and use one of these files in Ubuntu 14.04.
Have another answer? Share your knowledge.