Error proc_open(): fork failed – Cannot allocate memory after installing composer

Time:2022-11-24

1. Problem description:

When using composer to deploy the yii project on the linux server, “proc_open(): fork failed – Cannot allocate memory
Error proc_open(): fork failed - Cannot allocate memory after installing composer

That is, it prompts “Insufficient memory”, we can solve this problem by creating a swap partition.

2. Solution:

  • run firstfree -msee how much space
  • Run the following three commands in sequence in the command line environment
dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
mkswap /var/swap.1
swapon /var/swap.1
  • Example: [The following is the result of my running on the server]
dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 //the first instruction
1024+0 records in //This is the returned content
1024+0 records out //This is the returned content
1073741824 bytes (1.1 GB) copied, 10.0607 s, 107 MB/s //This is the returned content
mkswap /var/swap.1 //The second instruction
Setting up swapspace version 1, size = 1048572 KiB //This is the returned content
no label, UUID=f6280c41-21b4-4039-bc3e-c26284b47b0c //This is the returned content
swapon /var/swap.1 //The third instruction
swapon: /var/swap.1: insecure permissions 0644, 0600 suggested. //This is the returned content
  • explain:
dd copies a 1G file /var/swap.1 from the /dev/zero device

mkswap format /var/swap.1

swapon mounts the swap partition to the file system

Then enter free -m to view memory usage information
  • Finally, execute composer update again and it will be successful

Referenced blogs are:http://www.zfsphp.com/31.html