3
votes

I'm using laravel + composer . I'm loading way/generators package and when I run composer update give me this error:

Loading composer repositories with package information Updating dependencies (including require-dev)

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 67108864 bytes) in phar:///usr/local/Cellar/composer/1.0.0-alpha8/libexec/composer.phar/src/Composer/DependencyResolver/Solver.php on line 170

6

6 Answers

9
votes

I think, This is because composer update has used all the memory.

php -d memory_limit=1G /usr/local/Cellar/composer/1.0.0-alpha8/libexec/composer.phar update

This works for me on a mac.

Also check out to use composer install.

3
votes

If you are on a server with less amount of RAM like 512MB you will need to create swap memory. Here is how you do it on ubuntu

touch swap.img
chmod 600 swap.img

Using 1GB for swap

dd if=/dev/zero of=/var/swap.img bs=1024k count=1000
mkswap /var/swap.img
swapon /var/swap.img

Here is the full article https://www.digitalocean.com/community/tutorials/how-to-configure-virtual-memory-swap-file-on-a-vps

1
votes

I was having problem to install laravel with composer. Original command was:

composer global require "laravel/installer=~1.1"

And Error message was:

Loading composer repositories with package information Updating dependencies (including require-dev)

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 67108864 bytes) in phar:///usr/local/Cellar/composer/1.0.0-alpha8/libexec/composer.phar/src/Composer/DependencyResolver/Solver.php on line 170

Following command should work:

php -dmemory_limit=1G /usr/local/Cellar/composer/1.0.0-alpha8/libexec/composer.phar global require "laravel/installer=~1.1"
1
votes

In my case I encountered the same problem and manage to solve by halting the Apache and MySQL service and then proceeding to install the laravel application via composer.

The sudo service stop apache2 followed by sudo service stop mysql stop this in turn killed the application that were consuming memory I then proceeded to install the Laravel via the normal composer command once done I just restarted the service and everything was fine.

0
votes

I found solution, after read this post: https://github.com/composer/composer/issues/1898

Thank you to "Dynom, commented on Jul 4, 2013"

Needing 512MiB RAM for a package-manager is already a bit much, but I also exceed it. The interesting part is that I exceed 512 MiB RAM (up to around 800 MiB RAM according to my process output) when I use my private Satis repository (which is actually just a cache for all Github public repositories). I do not exceed it otherwise. Just by adding my satis repository, composer consumes almost 400 MiB more RAM

To all the others raising their PHP CLI memory_limit globally, I recommend against that. Instead I suggest to put it in the command line, like so:

php -dmemory_limit=1G {composer location} update 

Example:

php -dmemory_limit=1G bin/composer.phar update

Otherwise you could potentially miss certain unintended memory related behaviour in your own work.

Tested on: Debian version 6

0
votes

Do you have the last version of composer? I've fixed that problem with a simple update:

sudo composer self-update