4

I am trying to update my compose but i get the following error message can anyone tell me what this is.

root@linuxmachine:/var/www/html/# composer update
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Updating dependencies (including require-dev)

mmap() failed: [12] Cannot allocate memory

mmap() failed: [12] Cannot allocate memory
PHP Fatal error:  Out of memory (allocated 815800320) (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223

Fatal error: Out of memory (allocated 815800320) (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223
  • 2
    Since the errors say "Cannot allocate memory" and "Out of memory", my guess would be that it runs out of memory. – that other guy May 11 '20 at 20:31
  • Here is the output of `free -m total used free shared buff/cache available Mem: 985 136 660 37 188 675 Swap: 0 0 0` How can i allocate more memory and fix this problem –  May 11 '20 at 20:38
  • How much total memory do you have for the machine? – aynber May 11 '20 at 20:38
  • `df -h Filesystem Size Used Avail Use% Mounted on udev 480M 0 480M 0% /dev tmpfs 99M 632K 98M 1% /run /dev/vda1 9.6G 3.9G 5.7G 41% / tmpfs 493M 0 493M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 493M 0 493M 0% /sys/fs/cgroup /dev/vda15 105M 3.6M 101M 4% /boot/efi tmpfs 99M 0 99M 0% /run/user/1001` –  May 11 '20 at 20:42
  • 1
    If you only have 1G for the machine, it won't be enough to run Composer. You need at least 1.5G RAM to run it. – aynber May 11 '20 at 20:43
  • can we tweak this? Yes right now i am running this on 1G RAM –  May 11 '20 at 20:44
  • You might be able to use some disk space as swap (lots of google links out there, couldn't tell you now and that's a SuperUser question anyway), but I don't think you have enough disk space to recommend that, either. – aynber May 11 '20 at 20:48
  • currently i have 5.7G free disk space can we use this as a swap –  May 11 '20 at 20:51
  • You can run the composer command on another machine and then upload the result. If you go the route of using swap for this you'd best buckle up and get ready to wait a loooong time for it to complete. – Sammitch May 11 '20 at 21:44
  • @Sammitch i did not get you run the composer command on another machine and then upload the result??? –  May 11 '20 at 21:46
  • Thanks a lot i will check if that solve my issue @rob006 –  May 12 '20 at 00:42
  • Also, do not use `composer update` on your production server. Use it on your development environment and then use `composer install --optimize-autoloader --no-dev` on your production – padawanTony Dec 12 '20 at 12:55

1 Answers1

0

Usually that is a problem with the "memory_limit" directive in your php.ini. Try increasing the value assigned to memory_limit.

Jairo Erazo
  • 174
  • 1
  • 10