Question: 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?

Answer: 
From my experience, memory errors from composer usually means it is spending too much memory looking for the right combinations of packages to install, especially the version constraints are not specific enough. For example, ^5.2.4 matches 5.3 to 5.3.29, 5.4 to 5.4.45, etc. For each specific version and permutation, composer has to get the package's dependencies to check if all the constraints are met. This is usually when the memory consumption gets huge. 

Once the versions have been figured out, the installation phase uses much less memory. The resolved versions for each package are also stored in a composer.lock file so that the specific permutation installed can be replicated in other environments. **And this is the potential solution to your issue:** run composer update in your dev machine (which should have enough memory), deploy the updated composer.lock, and run composer install on the server. 

Composer install will always reference the existing composer.lock for the versions to install for each package, and thus should seldom run into memory issues.

For a reference on how to express version constraints in composer.json, check out <https://getcomposer.org/doc/articles/versions.md>
If you are still facing issues after updating your memory limit then the best thing to try is to run:

```
composer update --lock

```

This will update your lock file so that composer can run from it if you have changed your composer.json file.

You can now optimally run:

```
composer update

```

or

```
composer install

```