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: 
Memory limit errors
===================

Composer may sometimes fail on some commands with this message:

> 
> **PHP Fatal error: Allowed memory size of XXXXXX bytes exhausted <...>**
> 
> 
> 
> > 
> > Or in my case : 
> > 
> > 
> > Fatal error: Out of memory (allocated 1116733440) (tried to allocate
> >  134217728 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/Pool.php
> >  on line 339
> > 
> > 
> > 
> 
> 
> 

In this case, the PHP `memory\_limit` should be increased.

> 
> Note: Composer internally increases the `memory\_limit` to
>  **1.5G**.
> 
> 
> 

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

```

Composer also respects a memory limit defined by the `COMPOSER\_MEMORY\_LIMIT` environment variable:

```
COMPOSER_MEMORY_LIMIT=-1 composer.phar <...>

```

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

```
php -d memory_limit=-1 composer.phar <...>

```

This issue can also happen on cPanel instances, when the shell fork bomb protection is activated. For more information, see the [documentation](https://documentation.cpanel.net/display/68Docs/Shell+Fork+Bomb+Protection) of the fork bomb feature on the cPanel site.

---

To get loaded php.ini files location try:

```
php --ini

```

---

Source : (Composer [docs](https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors))
I'm on a Windows machine and I tried all of the answers from this question, but none of them worked. For me, it FINALLY worked after I ran composer **using the 64-bit version of PHP**.

To run composer using a local copy of PHP x64 you can do the following:

1. Download the zip file from here (I used the VC15 x64 Thread Safe version): <https://windows.php.net/download>
2. Unzip the file
3. Copy php.ini-development and rename to php.ini
4. Uncomment the `extension_dir = "ext"` line and any other php extensions you will need (such as `extension=gd2` or `extension=openssl`). If any other PHP extensions are needed for the update then it will tell you while running the command.

Working command:

```
"C:\path\to\php-7.2.23-Win32-VC15-x64\php.exe" -d memory_limit=-1 "C:/path/to/composer.phar" update

```

Source: <https://ourcodeworld.com/articles/read/816/how-to-solve-composer-install-update-error-virtualalloc-failed-0x00000008>