Magento 2.2.2 : Allowed memory size of 792723456 bytes exhausted (tried to allocate 184320 bytes)

Try following commands:

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
php bin/magento setup:di:compile
php bin/magento cache:flush
php bin/magento cache:clean

//To run command forcefully
php -f bin/magento

//To run command with memory limit 4G
php -d memory_limit=4G bin/magento

//To run command with max memory limit
php -d memory_limit=-1 bin/magento

If you are still facing issue then try following settings:

  1. [Magento2-root-folder]/index.php
ini_set('memory_limit',256);

OR

ini_set('memory_limit','-1');

Check current memory_limit value using CLI:

1. php -r "echo ini_get('memory_limit').PHP_EOL;"

2. php -i | grep memory

If the issue are still persist then increase the memory limit (e.g., up to 2048M) in the following places:

  1. [Magento2-root-folder]/.user.ini
memory_limit = 768M
  1. [Magento2-root-folder]/.htaccess (2 places)
php_value memory_limit 768M
  1. [Magento2-root-folder]/pub/.user.ini
memory_limit = 768M
  1. [Magento2-root-folder]/pub/.htaccess (2 places)
php_value memory_limit 768M

Issue should be resolved by now, if it is still there then disable your custom module and check again.


A quick solution is

php -dmemory_limit=6G bin/magento setup:static-content:deploy

Try this, Its worked for me.


792723456 bytes mean 756 MB. This is the value that Magento suggests and is the default on their sample configs(nginx in particular).

Do try everything that @Pratik Oza suggested and let me point to another place. Are you using php-fpm or a similar CGI? If so then please do check for memory limits there too.

In my case i am using nginx + php-fpm and i set the memory_limit per project using the

php_value[memory_limit] = [N]MB

Also if you are using a CGI then try this. First stop your webserver then restart you CGI and then start your webserver again.

The is a random problem i faced once that had me doing the above.If i did not then it was like nginx set it's own values to anything passed to php-fpm without caring for the values set on php.ini or fpm.conf.

EDIT: I see the problem was solved by editing the .user.ini. That means that it was actually nginx that passed another value and could also be the case i described. Just pointing this one out. Also to anyone reading the other answers please do not use set_init('memory_limit',-1) EVER.

I've seen a developer of mine using this to test out a mysql query optimization and the script reached a 35gigs ram which kept increasing until i killed it after 10mins. Just set the value to a decent threshold until you get to the running point and leave it there or fix the values or the perspectives user.ini/fpm.conf/fascgi parameter.