Header Ads

How to change memory_limit with magento 2

How to change memory_limit with magento 2

How to change memory_limit on magento 2

1, Use the command line


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

2, Change in php code


[Magento2-root-folder]/index.php

ini_set('memory_limit',256);

OR

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

3, Check current memory_limit value using CLI:


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

php -i | grep memory


4, Change config in project magento


[Magento2-root-folder]/.user.ini
memory_limit = 768M

[Magento2-root-folder]/.htaccess (2 places)
php_value memory_limit 768M

[Magento2-root-folder]/pub/.user.ini
memory_limit = 768M

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



No comments