Increasing composer memory limit on AWS (mmap() failed: [12] Cannot allocate memory)

Ive been trying to composer install and composer update on an EC2 AWS instance, and it always hangs on same package: symfony$thanks.json

Reading /root/.cache/composer/repo/https---repo.packagist.org/provider-symfony$thanks.json from cache

Im aware that I probably need to increase memory size for this action so i also ran it with the command

php -d memory_limit=-1 /var/www/html/composer.phar update/install

but it always get stuck on the same package, and hangs without moving (ive already waited 20 minute, just in case)

I tried to install this package by it self and then I got the error of:


mmap() failed: [12] Cannot allocate memory
PHP Fatal error:  Out of memory (allocated 557694976) (tried to allocate 20480 bytes) i                                                    n phar:///usr/local/bin/composer/src/Composer/Repository/ComposerRepository.php on line                                                     348

Fatal error: Out of memory (allocated 557694976) (tried to allocate 20480 bytes) in pha                                                    r:///usr/local/bin/composer/src/Composer/Repository/ComposerRepository.php on line 348
[[email protected] html]# mmap() failed: [12] Cannot allocate memory
bash: syntax error near unexpected token `failed:'

I already tried:

  1. composer clear-cache
  2. composer self-update
  3. all the php artisan clear commands
  4. updating composer and vendor on local and then upload them to AWS

What I didnt try:
the various swap method I read online, I dont really like to execute commands I dont fully understand.

any assistance will be highly appreciated

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *