13

I keep getting this memory error

PHP Fatal error:  Allowed memory size of 1610612736 bytes exhausted 
(tried to allocate 67108864 bytes) in 
phar:///usr/local/bin/composer/src/Composer/
   DependencyResolver/Solver.php on line 220

I have tried everything. Increased the memory limit a few times already. I've redownloaded composer and composer.phar. I cloned my repo on a fresh install and the first composer install worked. For some reason every attempt after causes this error.

I even removed any differences in files from the master branch and my branch that could be causing this.

PhP version 7.1.25 Composer version 1.7.2

Code I edited in a config.yml file

create_course_space_whitelist_expression: '"staff" in affiliations or 
"employee" in affiliations or "faculty" in affiliations or "guest" in 
affiliations or "GR" in student_level'

old code:

create_course_space_whitelist_expression: '"staff" in affiliations or 
"employee" in affiliations or "faculty" in affiliations or "guest" in 
affiliations

Not sure where else to look. I updated two created files within Vendor but I'm deleting vendor before running composer install

EDIT:

I've been able to narrow down the cause. composer install works fine the when working with a clean version of the repo branch. However, when any change is made to the composer.json file, it fails

d1596
  • 1,187
  • 3
  • 11
  • 25

7 Answers7

37

Running this command fixed it for me

php -d memory_limit=-1 /usr/local/bin/composer install

d1596
  • 1,187
  • 3
  • 11
  • 25
  • 4
    what about windows? i use windows 10 and this command worked for me, php -d memory_limit=-1 "C:\ProgramData\ComposerSetup\bin\composer.phar" update – saber tabatabaee yazdi May 24 '20 at 22:07
  • According to @sabertabatabaeeyazdi comment `php -d memory_limit=-1 "C:\ProgramData\ComposerSetup\bin\composer.phar" update` will work for windows – TarangP Jul 16 '22 at 13:55
19

In my case with Xampp with Windows 10

i just changed:

;memory_limit=512M 

by commenting this configuration, in php.ini to:

memory_limit =-1

then restart the Apache by xampp

enter image description here

saber tabatabaee yazdi
  • 4,404
  • 3
  • 42
  • 58
14

Update Composer to version 2 and it will resolve this issue automatically.

composer self-update --2

Note : argument --2 is optional. it will upgrade the current composer version to 2 only. Without it, the composer will update to the latest version (it's the same version 2 currently but in future, it may be 3)

Ravi Hirani
  • 6,511
  • 1
  • 27
  • 42
  • That solved the problem on Windows 10 with xampp installed. Do you have any idea what was this about? Thanks anyway! – Mycodingproject Jan 01 '21 at 12:50
  • @Mycodingproject : Thanks for the comment. Honestly, I don't have much idea but it seems there is a bug on Composer causing the memory to be exhausted by run `composer install` or `composer update`. – Ravi Hirani Jan 13 '21 at 00:47
  • Only used `composer self-update` to update to the latest version of composer – Onen simon Apr 06 '21 at 12:22
  • 1
    Using MAMP 6.6.4 on macOS Monterey, and this worked for me. Just run `composer self-update` without any other parameters. – uotonyh Dec 07 '22 at 19:07
7

what about windows?

i use windows 10 and this command worked for me,

php -d memory_limit=-1 "C:\ProgramData\ComposerSetup\bin\composer.phar" update
saber tabatabaee yazdi
  • 4,404
  • 3
  • 42
  • 58
5

Run COMPOSER_MEMORY_LIMIT=-1 composer install instead of composer install

Brn.Rajoriya
  • 1,534
  • 2
  • 23
  • 35
4

in WINDOWS you can use this:

set COMPOSER_MEMORY_LIMIT=-1

in windows 10 and with terminal and laragon it worked for me

mohammadreza khalifeh
  • 1,510
  • 2
  • 18
  • 32
0

COMPOSER_MEMORY_LIMIT=-1 composer update

try this it's working for me

Saif uddin
  • 459
  • 4
  • 7