简体   繁体   中英

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in Magento customer Create

I got this issue when creating the customer in magneto 2.

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /vendor/magento/framework/Model/ResourceModel/Db/VersionControl/Snapshot.php on line 47

due to this reason, I increased the memory limit up to 8 GB. but the issue remains.

/**
 * Register snapshot of entity data, for tracking changes
 *
 * @param \Magento\Framework\DataObject $entity
 * @return void
 * @SuppressWarnings(PHPMD.UnusedLocalVariable)
 */
public function registerSnapshot(\Magento\Framework\DataObject $entity)
{
    $metaData = $this->metadata->getFields($entity);
    $filteredData = array_intersect_key($entity->getData(), $metaData);
    $data = array_merge($metaData, $filteredData);
    $this->snapshotData[get_class($entity)][$entity->getId()] = $data;
}

issue raised in this line $data = array_merge($metaData, $filteredData);

vendor/magento/framework/Model/ResourceModel/Db/VersionControl/Snapshot.php

how to resolve this issue

Try this Allowed memory size of 792723456 bytes exhausted (tried to allocate 184320 bytes) https://magento.stackexchange.com/a/209993/49715

@Kashif answer help me a lot.

But none of the options not worked for me.

Problem solved.

My server is nginx. It memory limit defined in /etc/nginx/magento.conf

open the file and search

fastcgi_param  PHP_VALUE "memory_limit=

inside the below block

location ~ (index|get|static|report|404|503|info|cleanopcache)\.php$ {

}

after found that line, the memory limit has to set as 6144M

fastcgi_param PHP_VALUE "memory_limit=6144M \n max_execution_time=600";

after that, it works fine.

you able to find how much memory limit set in your Magento projects via debug log.

make log with ini_get('memory_limit');

hope this helps you all.

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
php bin/magento setup:di:compile
php bin/magento cache:flush
php bin/magento cache:clean

//To run command forcefully
php -f bin/magento

//To run command with memory limit 4G
php -d memory_limit=4G bin/magento

//To run command with max memory limit
php -d memory_limit=-1 bin/magento

ini_set('memory_limit',256);

OR

ini_set('memory_limit','-1');

follow full link here https://magento.stackexchange.com/questions/209976/magento-2-2-2-allowed-memory-size-of-792723456-bytes-exhausted-tried-to-alloc/209993#209993

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM