get Out of memory Error when update composer

-2

I want to update composer for laravel projects,I have 2 projects and updated worked on first But get this Error on other:

 >php -d memory_limit=-1  C:/composer/composer.phar  update --verbose --profile
[5.6MB/0.01s] Loading composer repositories with package information
[5.8MB/1.17s] Updating dependencies (including require-dev)
[581.3MB/35.03s] Dependency resolution completed in 0.006 seconds
VirtualAlloc() failed: [0x00000008] Not enough memory resources are available to process this command.
VirtualFree() failed: [0x000001e7] Attempt to access invalid address.
PHP Fatal error:  Out of memory (allocated 1631584256) (tried to allocate 12288 bytes) in 
phar://C:/composer/composer.phar/src/Composer/Package/Loader/ArrayLoader.php on line 56

Fatal error: Out of memory (allocated 1631584256) (tried to allocate 12288 bytes) in 
phar://C:/composer/composer.phar/src/Composer/Package/Loader/ArrayLoader.php on line 56

I Tried many solution like change memory_limit or delete vendor file But don't work for me.How I can solved this?

laravel
composer-php
out-of-memory
asked on Stack Overflow Nov 24, 2019 by hanie

1 Answer

0

When resolving a lot of dependencies composer can take up quite large amounts of memory. In order to allow it such amounts of memory the following steps can be taken:

  1. As Apokryfos mentioned make sure you are running 64-bit PHP, instead of 32. As 32 bit only supports 2GB memory (3GB if configured for it)
  2. Allow PHP to take up more memory (source: the composer troubleshoot page):
    • Adjust the memory_limit value in php.ini
    • Or run composer via php -d memory_limit=-1
  3. If you are running composer in a virtual machine, then make sure the machine itself has sufficient memory available. Laravel projects usually come with Homestead. In order to configure the available memory you can adjust the memory key in the homestead.yaml file.
  4. Additionally if you run composer in linux environment you should check if enough swap space if available

I would recommend anywhere between 2G and 4G memory for composer to function properly. If the issue still persists something else might be causing memory leaks.

You've nailed step 2 already, but I've included it anyway for other people to get the complete picture.

answered on Stack Overflow Nov 24, 2019 by PtrTon

User contributions licensed under CC BY-SA 3.0