Blog

Magento 2 – Allowed Memory exhausted error

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
and Restart the Apache.
Solution 2:-
A quick solution for memory limit in Magento 2 command is directly adding memory limit inside command.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *