Magento 2 Error Allowed Memory Exhausted Fix

Magento 2 Error Allowed Memory Exhausted Fix complete guide and clarification regarding the cause of the error, solution.

It is due to “allowed memory size of bytes exhausted”.The main purpose of this error is regarding the storage of memory.

If you use more RAM than what you specified in the file called PHP ini then this error gets occur.

Complete guide Magento 2 Error Allowed Memory Exhausted Fix

Using three different methods you can fix this error.

Magento 2 Error Allowed Memory Exhausted Fix
Allowed Memory Exhausted

During Magento 2 Installation this error also occurs.

Method 1:

Find the below value and made the change as given to fix the error of memory in the file


After making changes restart the Apache.

Method 2 :

You can also fix this error using the command line for memory limit and this can be done by adding an inside the command

The memory limit for the compilation command.

php -dmemory_limit=4G bin/magento setup:di:compile

The memory limit for deployment command

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

To fix the error you add the memory limit change 4G to the max.

Method 3 :

You can also fix by using the command instead of only bin/magento like given below

php -dmemory_limit=-1 bin/magento ....

Below is an example of the memory limit.

php -dmemory_limit=-1 bin/magento setup:upgrade
php -dmemory_limit=-1 bin/magento setup:di:compile

This error is complete regarding the memory limit which is to be done by configuration in PHP.

A parameter named, -dmemory_limit=-1 via command line helps to run PHP without memory limit.


With the help of the above method, the memory limit errors get fixed.

Leave a Comment