When running the Magento 2 indexer process from the CLI with command:

./magento indexer:reindex customer_grid

I get the following error:

PHP Fatal error:  Allowed memory size of 1073741824 bytes exhausted (tried to allocate 280224918230723 bytes) in /www/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php on line 228

The number of bites it tries to allocate is unrealistic. so increasing the memory limit is no option ( Also I think 1GB is already way too much.

I tried manually setting the index to invalid via the database and retrying to index. but this does not change anything. I also can’t find a matching table in the DB to flus as this did solve the problem in Magento 1.x.

The server runs on PHP version 7.0.0 and MariaDB version 10.1.9

  • try ./magento -d memory_limit=2048M indexer:reindex customer_grid. I had the same problem and this worked for me Commented Jun 30, 2016 at 10:58

3 Answers 3


It is a bug (a memory leak) in PHP 7.
PHP 7 is not ready yet to run such a complex software like Magento 2: you will get a lot of segfaults, memory leaks, etc.
I recommend to check it again in a month, may be it will be fixed in PHP 7.

  • We have downgraded to PHP 5.6 This indeed solved the above problem and lots of other issues we had. Thx! Commented Dec 24, 2015 at 14:34

Try this, it will take memory in run time:

For Linux

-dmemory_limit=2G magento indexer:reindex

For Windows as well as Linux

php -dmemory_limit=2G magento indexer:reindex

  • Hi Yogesh, Thanks for the suggestion. But as I stated in my initial question. Giving 2GB to a script is a bit extreme.... Also I am running all sites on PHP 7.0.7 which also solved the problem. Commented Jul 1, 2016 at 14:14
  • I mean its and one time solutions, i faced the same but after allocating memory size within the query on fly worked for me.. please post if you got anything on the same. Commented Jul 5, 2016 at 10:45

This is an old question, but there is a patch for this issue


It is also fixed in core if you upgrade to 2.2.X


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.