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: 
Katiak's answer worked but I had to modify it. You will need 4 GB of free space for this to work on a Linux machine. Make sure you `sudo` the commands if you're not root:

```
/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=4096
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1

```

Composer takes alot of memory for certain repositories like Drupal.

Essentially, this creates 4 GB of Swap memory from the hard drive which the CPU can use to complete the composer command.

The original solution seems to have come from this Github thread but I could be mistaken:

<https://github.com/composer/composer/issues/7348#issuecomment-414178276>

To load the swap at boot add the following line in `/etc/fstab`

```
/var/swap.1 none swap sw 0 0

```

You may want to backup your `fstab` file just to be on the safe side.

To reclaim the swap space do this:

```
sudo swapoff -v /var/swap.1
sudo rm /var/swap.1

```

If you get a message like this after turning on the swap...

```
swapon: /var/swap.1: insecure permissions 0644, 0600 suggested.

```

...change the permission if appropriate

```
sudo chmod 600 /var/swap.1

```
Increasing the `memory_limit` value on my `php.ini` did not solve my problem. 
What I did was: 

1. Delete composer.lock,
2. run composer update,

And that did the trick!