In this article, we will understand what is the cause of the issue and how we can resolve the issue ofΒ “Allowed Memory exhausted error” in Magento2.
The cause of the error βallowed memory size of bytes exhaustedβ is related to shortage of memory. The error occurs if you try toΒ use more RAM resourcesΒ than what you haveΒ specified in the php.iniΒ file through βmemory_limitβ.
Solution 1:-
In php.ini file, search and change the following values as below
max_execution_time=18000 max_input_time=1800 memory_limit=4G
For Compilation command,
php -dmemory_limit=4G bin/magento setup:di:compile
For Deployment
php -dmemory_limit=4G bin/magento setup:static-content:deploy
You can change as per 4G to max if issue not resolve.
Solution 3:-
You can easily fix it using this command instead of bin/magento:
php -dmemory_limit=-1 bin/magentoΒ ....
Examples:
phpΒ -dmemory_limit=-1 bin/magento setup:upgrade
phpΒ -dmemory_limit=-1 bin/magento setup:di:compile
This error isΒ related to the memory limit configuration in PHP. ParameterΒ -dmemory_limit=-1 allows to run PHP in the command line without memory limits.
Hope these solutions helped you to resolve the issue.
To install Magento2, click on this link.
Do comment below your feedback so that we will know our information is helping you or not.
Happy Learning !!
Thank You.