Php Fatal error: momory size exhausted when using

2019-07-18 07:56发布

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条回答
乱世女痞
2楼-- · 2019-07-18 08:28

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

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

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

查看更多
三岁会撩人
3楼-- · 2019-07-18 08:35

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.

查看更多
登录 后发表回答