I am trying to add HWIOAuthBundle to my project by running the below command.
composer require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle
HWIOAuthBundle github: https://github.com/hwi/HWIOAuthBundle
When I try to run composer require I am getting the out of memory error.
Using version ^0.6.0@dev for hwi/oauth-bundle Using version ^1.2@dev
for php-http/guzzle6-adapter Using version ^1.10@dev for
php-http/httplug-bundle ./composer.json has been updated Loading
composer repositories with package information Updating dependencies
(including require-dev)PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted
(tried to allocate 67108864 bytes) in
phar:///usr/local/Cellar/composer/1.4.2/libexec/composer.phar/src/Composer/DependencyResolver/Solver.php on line 220Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried
to allocate 67108864 bytes) in
phar:///usr/local/Cellar/composer/1.4.2/libexec/composer.phar/src/Composer/DependencyResolver/Solver.php on line 220
I tried setting the memory_limit to 2G in my php.ini file but did not work. I found my php.ini by running php -i | grep php.ini
asked Mar 10, 2018 at 18:19
Brian ChenBrian Chen
3,9613 gold badges9 silver badges15 bronze badges
7
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
Or, you can increase the limit with a command-line argument:
php -d memory_limit=-1 composer.phar require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle
To get loaded php.ini files location try:
php --ini
Another quick solution:
php composer.phar COMPOSER_MEMORY_LIMIT=-1 require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle
Or just:
COMPOSER_MEMORY_LIMIT=-1 composer require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle
answered Mar 10, 2018 at 18:25
AdamAdam
6,3571 gold badge12 silver badges23 bronze badges
9
In my case I was trying to require this package when I got this error.
You can run like this, and you don’t have to update the PHP INI file:
COMPOSER_MEMORY_LIMIT=-1 composer require huddledigital/zendesk-laravel
answered Sep 18, 2019 at 15:17
odubahodubah
4,2591 gold badge12 silver badges10 bronze badges
4
Another solution from the manual:
Composer also respects a memory limit defined by the COMPOSER_MEMORY_LIMIT environment variable:
COMPOSER_MEMORY_LIMIT=-1 composer.phar <...>
Or in my case
export COMPOSER_MEMORY_LIMIT=-1
composer <...>
answered Apr 19, 2019 at 7:57
2
Same problem, none of anything related to «memory_limit» worked, but..
composer self-update --2
..solved my problem. (upgrade: 1.10.17 -> 2.0.4)
answered Nov 5, 2020 at 10:49
Milla SenseMilla Sense
9214 silver badges4 bronze badges
5
On Windows 10;
Goto C:ProgramDataComposerSetupbin
Edit: composer.bat and add memory_limit=-1 in the last line as shown below.
@echo OFF
:: in case DelayedExpansion is on and a path contains !
setlocal DISABLEDELAYEDEXPANSION
php -d memory_limit=-1 "%~dp0composer.phar" %*
Problem solved 
TIGER
2,8645 gold badges35 silver badges45 bronze badges
answered Nov 18, 2019 at 17:07
Digital HumanDigital Human
1,5621 gold badge16 silver badges26 bronze badges
3
Since none of the previous answers included set it took me a bit to figure out how to do it in Windows without altering the php.ini, but here’s what worked for me:
set COMPOSER_MEMORY_LIMIT=-1
composer require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle
answered Mar 23, 2020 at 8:56
Arno van OordtArno van Oordt
2,7625 gold badges31 silver badges57 bronze badges
1
I have bypassed the problem in a Homestead Laravel (vagrant) virtual machine running the composer commands preceded by COMPOSER_MEMORY_LIMIT=-1:
Examples
To update Composer:
COMPOSER_MEMORY_LIMIT=-1 composer update
To install a package:
COMPOSER_MEMORY_LIMIT=-1 composer require spatie/laravel-translatable
answered Oct 7, 2020 at 11:49
Davide CasiraghiDavide Casiraghi
13.4k8 gold badges31 silver badges53 bronze badges
4
For this error in macOS Catalina and macOS Big Sur use this line:
php -d memory_limit=-1 /usr/local/bin/composer update --no-plugins
I used this line to update on Symfony 5. This command also worked with laravel 7.
answered Jul 13, 2020 at 21:49
juanitourquizajuanitourquiza
2,0401 gold badge28 silver badges51 bronze badges
2
Just set the memory_limit specifying the full route of your composer.phar file and update, in my case with the command:
php -d memory_limit=-1 C:/wamp64/composer.phar update
Acapulco
3,2938 gold badges37 silver badges50 bronze badges
answered Oct 12, 2018 at 19:47
3
Sometimes the problem is in the composer memory limit. In my case, I tried increasing the php memory limit but still got the error.
You can use COMPOSER_MEMORY_LIMIT=-1 to get around that.
Use it as a prefix:
COMPOSER_MEMORY_LIMIT=-1 composer require the/library
You have to prefix it again in the future.
Hope this helps.
answered Jul 9, 2020 at 4:00
meow2xmeow2x
2,00624 silver badges27 bronze badges
1
Just in case you get a composer error with:
Could not open input file: composer
run:
php -d memory_limit=-1 /usr/local/bin/composer require ...
answered May 24, 2020 at 8:16
0
For skipping memory limit and version error use the code below:
COMPOSER_MEMORY_LIMIT=-1 composer require <package-name> --ignore-platform-reqs
answered Jul 15, 2020 at 4:43
AbduhafizAbduhafiz
3,2285 gold badges37 silver badges47 bronze badges
what about windows?
i use windows 10 and this command worked for me,
php -d memory_limit=-1 "C:ProgramDataComposerSetupbincomposer.phar" update
answered Aug 2, 2020 at 23:58
0
Composer 2.0 preview is available now: https://github.com/composer/composer/releases
Fixed issue for me. You can set up a preview with composer self-update --preview
EDIT: Composer 2 with memory tuning released
answered Oct 4, 2020 at 17:31
For me, this works on shared hosting.
COMPOSER_MEMORY_LIMIT=-1 composer update
answered Apr 18, 2022 at 12:12
Adie RTAdie RT
5105 silver badges16 bronze badges
You can use a specific php Version when running Composer
If, like me, for some reason, you are using PHP 32 bits even though your computer is 64 bits, this will always limit the amount of memory allocated to Composer. I solved my problem this way:
- Install a 64 bits php version somewhere on your computer (let’s say in C:/php64)
- In composer (using cygwin in my case), run:
COMPOSER_MEMORY_LIMIT=-1 C:/php64/php.exe ../composer.phar update
answered Oct 16, 2019 at 19:43
RoubiRoubi
1,9491 gold badge24 silver badges36 bronze badges
1
in windows by xampp i just changed:
;memory_limit=512M
in php.ini to:
memory_limit =-1
then restart the Apache by xampp
this is the result:
; Maximum amount of memory a script may consume
; http://php.net/memory-limit
memory_limit =-1
;memory_limit=512M
answered Aug 6, 2020 at 8:45
1
On Mac php 7.4
run
php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/7.4
Loaded Configuration File: /usr/local/etc/php/7.4/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.4/conf.d
Additional .ini files parsed: /usr/local/etc/php/7.4/conf.d/ext-opcache.ini,
/usr/local/etc/php/7.4/conf.d/php-memory-limits.ini
If Additional .ini files parsed:
memory_limit needs to be changed in
/usr/local/etc/php/7.4/conf.d/php-memory-limits.ini
As Jose Seie writes, set memory to
memory_limit = -1 or memory_limit = 1G
answered Jul 22, 2020 at 20:06
Just want to share my situation on this matter.
Problem context:
- Running composer in a vagrant box.
- Was getting this message after try to run composer require «laravel-doctrine/orm:~1.4.13»:
Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52
Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.
- Have tried setting php.ini memory limit to -1. (still not working).
Solution:
-
Apparently my composer.json and composer.lock has some issues.
Ran $ composer validate, and the result was:
«The lock file is not up to date with the latest changes in composer.json, it is recommended that you runcomposer update.» -
So I ran $ composer update, and all dependencies are resolved. Imho, when the dependencies has some issues, maybe the tree building is out of sync, hence the out of memory issue.
Hope this helps anyone out there.
answered Jan 14, 2020 at 3:13
Steven YipSteven Yip
511 silver badge2 bronze badges
0
To override this and fix the issue on your local machine you can do the following changes within your php.ini configuration file.
- To locate your
php.iniconfiguration file you can use the following command:php --ini
After running this command you should see an output like the following:
Configuration File (php.ini) Path: /usr/local/etc/php/7.3
Loaded Configuration File: /usr/local/etc/php/7.3/php.ini <---- note the path
Scan for additional .ini files in: /usr/local/etc/php/7.3/conf.d
Additional .ini files parsed: /usr/local/etc/php/7.3/conf.d/ext-opcache.ini
The file we want to change is the Loaded Configuration.
-
Open and search for the
memory_limityou can set thememory_limit = -1to give an unlimited amount of memory to PHP processes or you can set512MB, 1G, 2G, 5G,....$ nano /usr/local/etc/php/7.3/php.ini
locate and set:
$ memory_limit = -1 or memory_limit = 1G
-
After saving your file, you can verify the PHP changes by running this command which will output the current memory settings in your
php.inifile:php -r «echo ini_get(‘memory_limit’).PHP_EOL;»
NOTE:
After saving, the new memory will be working. You don’t need to do anything else.
More info: https://support.acquia.com/hc/en-us/articles/360036102614-Overriding-memory-limits-during-local-development-with-Composer
answered May 22, 2020 at 18:19
Jose SeieJose Seie
85211 silver badges12 bronze badges
for Centos 7 use :
COMPOSER_MEMORY_LIMIT=-1 composer require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle
answered May 13, 2021 at 19:54
ignieligniel
631 silver badge7 bronze badges
Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52 Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.
set memory_limit to -1 works for me 
answered Jan 31, 2020 at 12:31
1
For Macbook:
run command sudo nano ~/.bash_profile to edit bash_profile then add alias composer="COMPOSER_MEMORY_LIMIT=-1 composer" in that file, then save and exit.
Hope this will solve the problem; Happy coding!
answered Jun 29, 2020 at 19:02
I condensed or packaged up the useful and accepted answer here into reusable (zsh) aliases/functions, for quicker and easier-to-remember reuse:
# composer high-memory
composermem() {
php -r "echo ini_get('memory_limit').PHP_EOL;"
}
alias composerbig='COMPOSER_MEMORY_LIMIT=-1 composer $1'
(php composer.phar is already aliased to composer on the system).
answered Jun 11, 2020 at 4:27
I solved this problem using this command COMPOSER_MEMORY_LIMIT=-1
Example: COMPOSER_MEMORY_LIMIT=-1 composer requires larval/ui
answered Aug 8, 2020 at 17:39
In My case i’ve tried to install the Laravel framework without stating xampp server (or apache server) in my windows system and i got following error
Fatal error: Allowed memory size of 1610612736 bytes exhausted
as soon as i started the xampp server (or apache server) it started to install the laravel framework and error gone away.
So actually sometimes you have to check this or else it will take longer time than usual and consume more memeory and in result size will be exhausted.
answered Jun 1, 2022 at 16:04
TarangPTarangP
2,6965 gold badges21 silver badges39 bronze badges
Make sure to not require a package before making sure the vendor folder exists.
Check if you have done composer install before. You may be just cloned the repository to your machine. So, you have to install the old packages before requiring a new one. Or you may want to include this option --profile to your composer command to see the timing and memory usage information.
answered Dec 17, 2019 at 9:18
Saud AlfadhliSaud Alfadhli
8251 gold badge8 silver badges11 bronze badges
In my case:
Windows 10 and Docker Desktop works:
docker-compose -f .docker/docker-compose.yml exec php env COMPOSER_MEMORY_LIMIT=-1 composer require fideloper/proxy
answered Jan 12, 2021 at 9:48
Hi,
I am using composer on my Laravel 6 project. However, somehow I always run into the problem is «Allowed memory size of 1610612736 bytes exhausted». I don’t know why but since a few days I have this problem and I don’t know why or where it does come from.
The curios thing is that I get exactly the same error on my development server. That means it must has to do something with the Laravel project itself. Because as I said, on my Mac as well as on my development server I get the exact same output with exact the same config and project.
The only workaround is php -d memory_limit=-1 composer update. But I cannot do this on my server because I am not the admin of the server and have a limited RAM usage. So, I do want to know what is causing this problem and how I can solve this.
Do you need any more information then those below?
I appreciate any kind of help!
Kind regards and thank you!
My composer.json:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"repositories": [
{
"type": "composer",
"url": "https://nova.laravel.com"
}
],
"require": {
"php": "^7.2",
"components/jquery": "^3.4",
"cybercog/laravel-nova-ban": "^1.1",
"emilianotisato/nova-tinymce": "^1.1",
"fideloper/proxy": "^4.0",
"glorand/laravel-model-settings": "^3.5",
"inspheric/nova-indicator-field": "^1.43",
"kabbouchi/nova-logs-tool": "^0.2.0",
"laravel/framework": "^6.2",
"laravel/nova": "~2.0",
"laravel/socialite": "^4.4",
"laravel/telescope": "^3.0",
"laravel/tinker": "^1.0",
"laravel/ui": "^1.1",
"laravelcollective/html": "^6.1",
"llaski/nova-scheduled-jobs": "^3.0",
"mad-web/nova-telescope-link": "^3.0",
"orangehill/iseed": "^2.6",
"paquettg/php-html-parser": "^2.1",
"pdewit/nova-external-url": "^1.0",
"phpunit/php-code-coverage": "^9.1",
"phpunit/phpunit": "^9.2",
"spatie/laravel-honeypot": "^1.4",
"spatie/laravel-medialibrary": "^7.19",
"spatie/laravel-permission": "^3.2",
"twbs/bootstrap": "^4.3",
"vyuldashev/nova-permission": "^2.9",
"yoeunes/toastr": "^1.2"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.2",
"barryvdh/laravel-ide-helper": "^2.6",
"brianium/paratest": "^4.1",
"facade/ignition": "^1.4",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
],
"files": [
"app/Helpers/helper.php",
"app/Helpers/commentsHelper.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\Foundation\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r "file_exists('.env') || copy('.env.example', '.env');""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
],
"post-update-cmd": [
"Illuminate\Foundation\ComposerScripts::postUpdate",
"@php artisan ide-helper:generate",
"@php artisan ide-helper:meta"
]
}
}
Output of composer diagnose:
Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0 87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B 0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
Composer version: 1.10.10
PHP version: 7.3.18
PHP binary path: /usr/local/Cellar/php@7.3/7.3.18_1/bin/php
OpenSSL version: OpenSSL 1.1.1g 21 Apr 2020
When I run this command:
(Basically any commands where I install, remove or update packages)
composer update
composer install
...
...
I get the following output:
PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/Cellar/composer/1.10.7/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223
Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/Cellar/composer/1.10.7/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223
Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.
A recent attempt to run an update composer (regular activity for many of us), I had a memory limit issue. This was surprising because the memory setting via Plesk is set to 2G. Yet through Terminal it was showing only 128MB. What gives??
The error I was seeing:
PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 32 bytes) in phar:///usr/lib64/plesk-9.0/composer.phar/src/Composer/DependencyResolver/Pool.php on line 339 Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 32 bytes) in phar:///usr/lib64/plesk-9.0/composer.phar/src/Composer/DependencyResolver/Pool.php on line 339 Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.
or
PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/psa/var/modules/composer/composer.phar/src/Composer/DependencyResolver/Solver.php on line 223 Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/psa/var/modules/composer/composer.phar/src/Composer/DependencyResolver/Solver.php on line 223 Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.
I have had both of these errors (at different times). However, the solution for me was the same in both instances.
How to investigate this error
In this instance, the PHP memory_limit was being applied to the wrong PHP version. As noted above the respective PHP version is showing 128MB and needs to be increased to something bigger. How do you get the current memory_limit value? By running the following command through shell program like Terminal:
php -r "echo ini_get('memory_limit').PHP_EOL;"
This will confirm the current memory_limit as noted in the error being
128M
Even though Plesk had a different memory limit, composer wasn’t utilising that, but rather the setting in the php.ini file. Subsequently, try increasing the limit in your php.ini file. For me the php.ini is located in /etc directory. However, it might not be in the etc directory or it is, yet it is not the php.ini file being use.
How to find the php.ini in use? In shell run the command:
php -i
This will output the phpinfo() data… displaying something like
PHP Version => 7.3.25 Build Date => Nov 26 2020 20:28:14 Configure Command => './configure' '--docdir=/opt/plesk...'
Do a search for php.ini to see the result being something like:
Configuration File (php.ini) Path => /etc or Configuration File (php.ini) Path => /opt/plesk/php/7.3/etc Loaded Configuration File => /opt/plesk/php/7.3/etc/php.ini
Resolving the error
Now that you know the php.ini file being used (for me it was /opt/plesk/php/7.3/etc), you can edit the php.ini file through using the vi command either going to the directory path and using:
vi php.ini
or
vi /opt/plesk/php/7.3/etc/php.ini
While in edit mode, perform a quick search rather than scrolling through the file using /{search term}. In this instance search for memory_limit, subsequently the find entry will be
/memory_limit
This will take you to the location of memory_limit, looking something like
; Maximum amount of memory a script may consume (128MB) ; http://www.php.net/manual/en/ini.core.php#ini.memory-limit memory_limit = 128M
Use -1 for unlimited or define an explicit value like 2G (remember to enter edit / insert mode you will need to press i). Change the memory_limit to something bigger. For me I changed it to 2G.
memory_limit = 2G
Save and close vim, press [Esc] key and type :wq!
[esc]:wq!
Done.
Always a good idea to run through the above script again and test the memory_limit value has been updated and now reflects your new value rather than 128MB.
How come I changed the memory_limit from 128M to 2G?
At face value, yes this seems quite a significant jump. A clue indicating that you need to have a decent jump is in the error itself. Actually there are two areas of css:
- Allowed memory size of 1610612736 bytes exhausted
- Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors
Allowed memory size 1610612736
Converting 1610612736 bytes to GB is 1.61G. Therefore the current allocation of 128M is severely inadequate.
Check memory-limit-errors message
In the last line of the error message there is a reference to a URL on the getcomposer.org site. If you go to this site you will read
Composer may sometimes fail on some commands with this message:
PHP Fatal error: Allowed memory size of XXXXXX bytes exhausted <...>
In this case, the PHP memory_limit should be increased. Note: Composer internally increases the memory_limit to 1.5G.
The site also outlines setting an unlimited amount, which can be achieved by entering -1. Personally, I prefer to set a finite allocation and test the allocation. If you want to monitor how hungry Composer is you can open a second window and log in to the server. This while the composer command is running, in the second window run the command
free -m
This will output how the current memory resources are being allocated.
Error — E212: Can’t open file for writing
On a recent change to the memory_limit, I had an E212: Can’t open file for writing error. This was a quick resolve as I had logged in to the server as a user other than root. The memory_limit change required me to be a root user. Once I had another connection through shell as a root user the update was seamless.
Quick snapshot of your memory size by the error
If you aren’t sure what your PHP memory limit is set to, it’s helpfully included in the error message. The size is reported in bytes:
PHP: Fatal Error: Allowed Memory Size of 8388608 Bytes Exhausted — 8 MB
PHP: Fatal Error: Allowed Memory Size of 16777216 Bytes Exhausted — 16 MB
PHP: Fatal Error: Allowed Memory Size of 33554432 Bytes Exhausted — 32 MB
PHP: Fatal Error: Allowed Memory Size of 67108864 Bytes Exhausted — 64 MB
PHP: Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted — 128 MB
PHP: Fatal Error: Allowed Memory Size of 268435456 Bytes Exhausted — 256 MB
PHP: Fatal Error: Allowed Memory Size of 536870912 Bytes Exhausted — 512 MB
PHP: Fatal Error: Allowed Memory Size of 1073741824 Bytes Exhausted — 1 GB
