Magento2: PHP memory issue "Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to alloc ate 4096 bytes)"

Created on 26 Feb 2018  路  12Comments  路  Source: magento/magento2

PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to alloc ate 4096 bytes) in \vendorzendframeworkzend-stdlib \src\PriorityQueue.php on line 281

I am using Magento 2.2.2 version and Migrated old Magento 1.9.2 site to Magento 2.2.2.
While migration faced some issues but I have resolved it. Now I am trying to add new extension with the store and to get it installed and enable it I am running the Magento commands but not it is giving me this error in the terminal.

Steps to reproduce

  1. After Data migration I am facing this issue.
  2. I am trying to use Magestore Banner slider extension with Magento 2.2.2
  3. Errors are genrated while running the commands in the terminal.

Expected result

trying to run following commands

php bin\magento cache:clean
php bin\magento cache:flush
php bin\magento setup:upgrade
php bin\magento indexer:reindex 

Expected result : Run the commands install and enable the extension.

Actual result

PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 4096 bytes) in \vendorzendframeworkzend-stdlib\src\PriorityQueue.php on line 281

I have set memory_limit= 8G but still it is showing memory allocation issue.
All possible caches cleaned, folders under var/ removed, but getting same result.
Have already searched so any reference links and tried the solutions given to still getting same errors.

Format is not valid

Most helpful comment

Did you try php -d memory_limit=-1 bin/magento setup:upgrade?

All 12 comments

Hi @aakash1213. For migration related issues please use the correct repository: https://github.com/magento/data-migration-tool

Thank you.

@magento-engcom-team please re-open this issue. I experience it with a fresh install of magento 2.2.5, without migration.

@JoshuaFlood please make sure to increase the memory_limit of PHP.

@DanielRuf I have set the memory limit in my server's php.ini to 2048M. I have also set it in Magento's .htaccess and .ini files. Actually, since updating all of the entries from 768 to 2048 I can't execute any magento commands at all. I receive an error saying memory is exhausted at 2M... So it is obviously being overridden somewhere. I've checked the relevant folders' memory limit and all are displaying as expected. Will try with a fresh install next week. Not at home until then so can only test with existing install.

Did you restart the server after this?

@DanielRuf yes I have tried that and I still can't execute any commands. Even something like magento module:status throws an 'out of memory' error.

Try adding the memory_limit parameter to php bin/magento ...

Thanks! I'll just stick with it. I'm already aware that this is an option, it just seems ludicrous to me that Magento would even suggest things like adding the bin/magento command as an environment variable or suggesting their dysfunctional 'two-user' setup. Ideally, I'd just like to find a solution which allows me to run magento commands in their standard format, or at least see some explanation within the official documentation of common issues relating to permissions or PHP settings, because right now the best support seems to be from community members taking stabs in the dark. Hopefully Adobe will have a positive influence.

like adding the bin/magento command as an environment variable or suggesting their dysfunctional 'two-user' setup.

I do not fully understand. You just have to provide the PHP CLI options for the memory_limit parameter to increase it during the steps.

In general your PHP CLI version has different settings than the version running your website.

Did you try php -d memory_limit=-1 bin/magento setup:upgrade?

Yes DanielRuf, that work for me!
Thanks!

I executed commands like:

/opt/plesk/php/7.2/bin/php -d memory_limit=-1 bin/magento setup:upgrade
/opt/plesk/php/7.2/bin/php -d memory_limit=-1 bin/magento setup:di:compile
/opt/plesk/php/7.2/bin/php -d memory_limit=-1 bin/magento setup:static-content:deploy -f es_ES
/opt/plesk/php/7.2/bin/php -d memory_limit=-1 bin/magento indexer:reindex
/opt/plesk/php/7.2/bin/php -d memory_limit=-1 bin/magento cache:clean
/opt/plesk/php/7.2/bin/php -d memory_limit=-1 bin/magento cache:flush

Thanks

Was this page helpful?
0 / 5 - 0 ratings