I recently migrated data from Magento 1.8.1 to Magento 2.1.7, which includes around 700,000 customers.

After migration, I am running this command:

php -d memory_limit=3G bin/magento indexer:reindex customer_grid

But I am still getting a memory error:

PHP Fatal error:  Allowed memory size of 3221225472 bytes exhausted
(tried to allocate 20480 bytes) in /<doc-root>/vendor/magento/zendframework1/
library/Zend/Db/Statement/Pdo.php on line 291

Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors
for more info on how to handle out of memory errors.

I have set memory_limit in php.ini to 3 GB. I can confirm that:

$ php -r "echo ini_get('memory_limit').PHP_EOL;"

I am using SSD so cannot create SWAP as per the instruction in the link above.

What can I do to fix this problem?

  • 3
    try with more memory like this: php -d memory_limit=5G bin/magento indexer:reindex customer_grid
    – kunj
    Jun 9, 2018 at 12:24

2 Answers 2


Increasing the server's memory from 4GB to 8GB, then assigning 7GB for PHP fixed the issue, Magento was able to re-index the customer grid in 10 minutes.


Possible solutions could be

  • to set PHP > memory_limit = -1
  • in data migration tool > config.xml = 1000 or 500

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.