2
votes

When triing to install FOSuserbundle with composer I got the following message in the Terminal:
"PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 79 bytes) in phar:///Users/myname/MyWebSite/composer.phar/src/Composer/ DependencyResolver/Solver.php on line 177"

How can I fix it?


EDIT / FURTHER INFORMATION

In Terminal typing: php -r "echo ini_get('memory_limit').PHP_EOL;"
get me the following: 128M
while php.ini (App/MAMP/conf/php5.4.4/php.ini) has the following line: memory_limit = 32M

why different value? how can I change the value so that composer can install the bundle?

I tried the following in terminal but got an error: php -d memory_limit=512M composer.phar/src/Composer/DependencyResolver/Solver.php
error ==> Could not open input file: composer.phar/src/Composer/DependencyResolver/Solver.php

2
composer is an archive, not just a file, its a self contained application, written in PHP, contained in a phar archive (cf the PHAR extension)Elias Van Ootegem
@ Bulk. I tried the following line (see also my Edit in main question) php -d memory_limit=512M composer.phar/src/Composer/DependencyResolver/Solver.php but this is not working. how can I change the memory_limit? which value should I set 512M?Alexis_D
i have already answered to this issue stackoverflow.com/a/28068875/4098311Halayem Anis
I change php.ini memory_limit from 32M to 42M and got the same message when updating composer.phar in terminal.Alexis_D

2 Answers

2
votes

I've solved this in the past by using simply:

php -d memory_limit=1G /usr/local/bin/composer update --prefer-dist --no-dev

Where the no-dev may help reduce the memory footprint too - certainly speed.

0
votes

Composer should be run with at least 1 GB of allowed and available memory. If your machine has less memory physically installed, you should consider upgrading or using a different machine - otherwise the process will start swapping and taking huge amounts of time, so something that should be done in less than a minute will take days.

If you are unable to raise the memory limit for PHP, you are out of luck unfortunately. Composer needs some huge data structures when updating.