PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes)

Time:2020-10-31

Original link:https://www.wjcms.net/archives/2020-10-05-20-03-19

An error occurred when using composer to install the expansion pack today, as follows:

PHP Fatal error:  Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///www/server/php/74/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///www/server/php/74/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223

Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.#


So tossed for a long time, and finally succeeded, write down the article, record, share with you.

The articles found on the Internet are as follows,

Output the memory configuration information through the above prompt composer link

php -r "echo ini_get('memory_limit').PHP_EOL;"
Output 128M

I try to modify it php.ini File, my path is / etc / php7 / apache2/ php.ini , modify the memory inside_ Limit = - 1. After restarting Apache, the error of running composer update is the same as that of PHP command and Apache 2 php.ini The files are not the same, so

[email protected]:/srv/www/htdocs/sfs> sudo find / -name "php.ini"[sudo] password for root: /etc/php7/cli/php.ini/etc/php7/apache2/php.ini/etc/php7/fastcgi/php.ini
I tried to modify / etc / php7 / cli/ php.ini  Memory in_ The value of limit is - 1. After modification, run

php -r "echo ini_get('memory_limit').PHP_EOL;"
The output result is: - 1. It feels that the modification is successful, and the composer update can also run normally.

It can be successfully solved, but it is not safe. It is not recommended here.

The ultimate solution

Here’s my recommended method, which is to use the command to install.

php -d memory_limit=-1 /usr/bin/composer require xxxx/xxxxxxx

You can see that the installation is successful.

be careful

/ usr / bin / composer in the above command is the installation address of composer
Available
composer -h
Command.

Follow me and share more articles every day.

Recommended Today

MVC and Vue

MVC and Vue This article was written on July 27, 2020 The first question is: is Vue an MVC or an MVVM framework? Wikipedia tells us: MVVM is a variant of PM, and PM is a variant of MVC. So to a certain extent, whether Vue is MVC or MVVM or not, its ideological direction […]