Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer Update failed -- out of memory

I got this error when running composer.phar update on my VM:

PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 144115188075867549 bytes) in phar:///bin/composer.phar/src/Composer/Util/RemoteFilesystem.php on line 179

The composer.json, if needed:

{         "description" : "The CodeIgniter framework",         "name" : "codeigniter/framework",         "license": "MIT",         "require": {                 "php": ">=5.2.4",                 "videlalvaro/php-amqplib": "2.5.*"         },         "require-dev": {                 "mikey179/vfsStream": "1.1.*",                 "videlalvaro/php-amqplib": "2.5.*"         } } 

The VM just recently recovered from a bad disk sector problem, and the guy running the VM said that the VM has been moved to a new disk. There are only Java, PHP, httpd, postgre, rabbitmq and the website itself in my VM, and it already ran perfectly for about 4 months before this happened. I'm using PHP 5.6.11. Can anyone help please?

like image 817
Aldibe Avatar asked Oct 23 '15 09:10

Aldibe


People also ask

How do I change my composer memory limit?

COMPOSER_MEMORY_LIMIT=-1 composer. phar <...> Or, you can increase the limit with a command-line argument: php -d memory_limit=-1 composer.

How do I fix the allowed memory size 1610612736 bytes exhausted?

Allowed memory size of 1610612736 bytes exhausted ??? can someone help me this? Try prefixing your command with COMPOSER_MEMORY_LIMIT=-1 . This will remove the memory limit for the execution of the command.


1 Answers

Check the Composer's troubleshooting wiki, especially the memory limit errors section.

For instance, by running the composer like this:

php -d memory_limit=-1 `which composer` update 

I get no error anymore. So it is probably an insufficient memory issue that can be solved inline, without altering your default PHP configuration.

What the command above does is that it sets the PHP CLI memory limit to "unlimited" (ie. -1) and then it runs the inline composer update command.

Please note that instead of `which composer` you should probably use the real path of your composer.phar PHP script. The which composer written inline (like in my example above) will be inline solved to your composer.phar full path (you may use whatever form you like).

Note: in case both the physical and virtual memory is exceeded the above solution might fail as well. If that is the case then the obvious solution would be to increase your system's virtual memory then try again.

like image 136
Eugen Mihailescu Avatar answered Oct 14 '22 15:10

Eugen Mihailescu