0

I have a cloud in the digital ocean where it has 1 GB of ram. I need to install a docker, laravel, mysql, nginx environment, I found the laradock and installed it normally but when running the composer in the container I am returning a memory limit error.

Error running: composer install

root@b9864446a1e1:/var/www/site# composer install
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 677388288) (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52

Fatal error: Out of memory (allocated 677388288) (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52

Error when trying to change memory.

WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.

Noscin
  • 59
  • 1
  • 9
  • Does this answer your question? [Composer update memory limit](https://stackoverflow.com/questions/36107400/composer-update-memory-limit) – Wahyu Kristianto Feb 17 '20 at 13:46
  • no,when executing the update command the error below occurs!!! mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory PHP Fatal error: Out of memory (allocated 266338304) (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/Package/Loader/ArrayLoader.php on line 241 Fatal error: Out of memory (allocated 266338304) (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/Package/Loader/ArrayLoader.php on line 241 – Noscin Feb 17 '20 at 13:53
  • Are you running on VPS? – Wahyu Kristianto Feb 17 '20 at 14:00
  • Yes, in the Digital Ocean a cloud of 1gb ram. – Noscin Feb 17 '20 at 14:04

1 Answers1

2

This could be happening because the VPS runs out of memory and has no Swap space enabled.

free -m

total used free shared buffers cached
Mem:  xxxx xxx xxxx x x xxx
-/+ buffers/cache: xxx xxxx
Swap: 0 0 0

To enable the swap you can use for example:

/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1

You can make a permanent swap file following this tutorial from DigitalOcean.

Wahyu Kristianto
  • 8,719
  • 6
  • 43
  • 68