Skip to content

Instantly share code, notes, and snippets.

@srmklive
Last active April 11, 2016 09:19
Show Gist options
  • Save srmklive/b87549aeb9a65da7bf938a13410c30ff to your computer and use it in GitHub Desktop.
Save srmklive/b87549aeb9a65da7bf938a13410c30ff to your computer and use it in GitHub Desktop.
Remove composer error: proc_open(): fork failed - Cannot allocate memory
When running composer commands, sometimes you may see Download exception errors, and also this error message:
```
proc_open(): fork failed - Cannot allocate memory
```
To correct this error, you need to enable swap. You can enable swap by running the following commands:
```
/bin/dd if=/dev/zero of=/swapfile bs=1M count=4096
/sbin/mkswap /var/swapfile
/sbin/swapon /var/swapfile
```
The above stated solution is a temporary solution. To enable swap permanently, you need to do the following:
```
sudo fallocate -l 4G /swapfile // Create a 4GB swap file
ls -lh /swapfile
sudo chmod 600 /swapfile // Only root user can read the file
ls -lh /swapfile
sudo mkswap /swapfile // Setup swap space
sudoswapon /swapfile // Enable swap space
sudo swapon -s // Check if swap is enabled
free -m // Check if swap is showing in memory
// To make swap permanent
sudo nano /etc/fstab
/swapfile none swap sw 0 0 // Add it at end of line
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment