Composer Running Out of Memory on Every Project, MAC Os X

Composer running out of memory on every project, Mac OS X

EDIT: Before going any further always make sure you're running the latest version of composer, you can update it via composer self-update

When you run composer update it will calculate the most up-to-date gitref for each of your libraries (or the latest release) and then will install that version of the library. It will then store these versions in the composer.lock file.

When you run composer install, it simply installs the versions defined in the composer.lock file.

The reason composer update takes so long and uses so much memory is because it has to trace every library's version, compare it with the version you have defined in your composer.json and then check all of that library's dependencies. This is quite an intensive process.

I find that running composer using hhvm (you can install it here) speeds up the composer update process massively.

Short of that, you just have to live with the high memory usage and increase it in your php.ini file. Make sure you update the one that is relevant for your CLI.

EDIT: You should never run composer update in the production environment. You should only update your dependencies when you're developing, and then use composer install to install your last used set of composer dependencies when you're in a production environment.

Composer Update failed -- out of memory

Solved by deleting the whole vendor folder, and then doing the composer update again, and it works... somehow. I don't even understand :v

Composer require runs out of memory. PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted

To get the current memory_limit value, run:

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

Try increasing the limit in your php.ini file (ex. /etc/php5/cli/php.ini for Debian-like systems):

; Use -1 for unlimited or define an explicit value like 2G
memory_limit = -1

Or, you can increase the limit with a command-line argument:

php -d memory_limit=-1 composer.phar require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle

To get loaded php.ini files location try:

php --ini

Another quick solution:

php composer.phar COMPOSER_MEMORY_LIMIT=-1 require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle

Or just:

COMPOSER_MEMORY_LIMIT=-1 composer require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle

OSX composer increase memory limit

To run composer with no memory limit, first find out where your composer binary is with which composer. Use the resulting path like so:

php -d memory_limit=-1 /usr/local/bin/composer require etc/etc

You could also alias this: alias composer="php -d memory_limit=-1 /usr/local/bin/composer", which would allow you to call composer as you would normally.

Add that line to your bash profile if you want to use composer without limits permanently.

Composer update memory limit

When you run composer update, the OS will look into the configured paths and try to locate an executable file with that name.

When running php composer update, the composer string is treated as a parameter to PHP, which is not searched in any paths. You have to provide the full path in order to run it.

Running which composer will tell you where the OS finds the composer executable, and then you simply use the full path in the PHP command:

$>which composer
/usr/local/bin/composer

$>php -d memory_limit=512M /usr/local/bin/composer update
...

Note that 512MB might be too few. My perception is that it will happily take 1GB or more, depending on the number of dependencies you use and the variety of versions that you theoretically allow, i.e. if you allow Symfony ~2.3, then you make Composer deal with a lot more possible versions compared to using ~2.7.

Also note that running Composer on the production machine is not the best idea. You would have to have access to Github, maybe provide access credentials, have VCS tools installed, and you will easily break your site if any of the remote hosting servers is offline during your update. It is a better idea to use Composer on a deployment system that does all the preparation, and then moves all the files onto the production server.

Update

It's the year 2020 now, and the way Composer manages its memory has changed quite a bit. The most important thing is that Composer will increase the memory limit by itself if it encounters a limit set too low. This however immediately triggers the problem of running out of memory on machines that have too few memory installed. You can make Composer use less memory by setting the environment variable like COMPOSER_MEMORY_LIMIT=512M, but this will create problems if Composer would need more memory to correctly operate.

My main point remains true: Do not run Composer on machines that have too few memory installed. You potentially need 1.5 GB of free memory to be able to update everything.

Running php and composer under OSX results in timed out error

The problem was caused by activated IPv6 in my networksettings for my Wi-Fi connection.

Here is the Link to the composer-website.

Short way to handle it:

  1. deactivate IPv6 for your used connection networksetup -setv6off Wi-Fi
  2. run your composer-commands
  3. reactivate IPv6 for your used connection networksetup -setv6automatic Wi-Fi

If you don't need IPv6 on your machine, you can leave it disabled.

Composer create-project laravel memory error

If you install it through Homebrew it seems that Composer package is not up to date.

If this is your case you can run from command line composer self-update and retry.

Running out of memory PHP Laravel 5.6

The problem was with DB connection, i used mysql 5.7 in Ubuntu and mysql 8 in mac OS. I fixed the problem by adding

'modes'  => [
'ONLY_FULL_GROUP_BY',
'STRICT_TRANS_TABLES',
'NO_ZERO_IN_DATE',
'NO_ZERO_DATE',
'ERROR_FOR_DIVISION_BY_ZERO',
'NO_ENGINE_SUBSTITUTION',
]

in database.php



Related Topics



Leave a reply



Submit