I am facing allowed memory size of bytes exhausted when ever trying to login customer in magento 2.3.2

I have used beforeAuthenticate plugin to do some functionality after sometime customer can not logging In. i have disabled my custom extension but still facing same issue.

File 1. Demo\Common\etc\di.xml

<type name="Magento\Customer\Model\AccountManagement">
    <plugin name="xxx_set_password_if_empty" type="Demo\Common\Plugin\Customer\Model\AccountManagement" sortOrder="1"/>

File 2 Demo\Common\Plugin\Customer\Model\AccountManagement.php

namespace Demo\Common\Plugin\Customer\Model;

use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Customer\Model\CustomerRegistry;
use Magento\Framework\Encryption\EncryptorInterface as Encryptor;
use Magento\Framework\Exception\InvalidEmailOrPasswordException;
use Magento\Framework\Exception\NoSuchEntityException;

class AccountManagement
private $customerRegistry;
private $customerRepository;
private $encryptor;
private $connection;

public function __construct(
    CustomerRegistry $customerRegistry,
    Encryptor $encryptor,
    \Magento\Framework\App\ResourceConnection $resource,
    CustomerRepositoryInterface $customerRepository

) {
    $this->customerRegistry = $customerRegistry;
    $this->encryptor = $encryptor;
    $this->_resource = $resource;
    $this->customerRepository = $customerRepository;
public function beforeAuthenticate(\Magento\Customer\Model\AccountManagement $subject, $username, $password)

    try {
        $customer = $this->customerRepository->get($username);
    } catch (NoSuchEntityException $e) {
        throw new InvalidEmailOrPasswordException(__('Invalid login or password.'));

    /* START : Logic to set customer's password if found empty within our database */
    $customerSecure = $this->customerRegistry->retrieveSecureData($customer->getId());

    try {
        if(empty($customerSecure->getData('password_hash'))) {

    } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
            return array($username, $password);
    return array($username, $password);
    /* END : Logic to set customer's password if found empty within our database */

  • When you're getting this error at the time of compilation? – Kishan Savaliya Nov 15 '19 at 9:51
  • when customer trying to loggin – Manish Maheshwari Nov 15 '19 at 9:53
  • Can you please update your Plugin code here with di.xml file content ? – Kishan Savaliya Nov 15 '19 at 9:54

You have to increase memory size, there are 3 ways to increase memory size:

  1. Index.php: (ini_set("memory_limit","-1");
  2. php.ini: (memory_limit = 512M);
  3. .htaccess: (php_value memory_limit 512M);

You can find these links useful: php memory limit

Magneto 2 memory error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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