Using Magento 2.4.1. Running commands from Cpanel Terminal.
What am I missing to fix out of memory messages?
php -i | grep "memory_limit"
result ==> memory_limit => 8192M => 8192M
then ran
php bin/magento setup:di:compile Compilation was started. Repositories code generation... 1/9 [===>------------------------] 11% < 1 sec 87.0 MiB mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory Fatal error: Out of memory (allocated 190840832) (tried to allocate 135168 bytes) in /home/xxxxt/public_html/setup/src/Magento/Setup/Module/Di/Code/Reader/FileClassScanner.php on line 115
thereafter
php -dmemory_limit=8G bin/magento setup:di:compile Compilation was started. Repositories code generation... 1/9 [===>------------------------] 11% < 1 sec 87.0 MiBOut of memory php -dmemory_limit=5G bin/magento setup:di:compileCompilation was started. Repositories code generation... 1/9 [===>------------------------] 11% < 1 sec 87.0 MiBOut of memory php -dmemory_limit=8G bin/magento setup:di:compile Compilation was started. Repositories code generation... 1/9 [===>------------------------] 11% < 1 sec 87.0 MiBOut of memory
Hi,
I think there should be a space after -d and I used php-cli with full path whenever I get any issues.
Lately havent got any issue, earlier my command was...
/usr/local/php71/bin/php-cli -d memory_limit=6G bin/magento setup:di:compile
(pl change above as per your version of php & memory)
Hi Shailesh,
I need to run the commands in cpanel terminal. Using php 7.4. Please state correct syntax. Thanks.
error when I run it from root
[root@server ~]# /usr/local/php74/bin/php-cli -d memory_limit=8G bin/magento setup:di:compile bash: /usr/local/php74/bin/php-cli: No such file or directory
For me, I have php-cli in /usr/local/php74/bin/
So, it doesnt give file not found for me.
Fix Allowed Memory Exhausted Error When Compile Code In Magento 2 :- Sometimes when we execute compile or deploy command it gives allowed memory size exhausted error.
<span class="typ">Fatal</span><span class="pln"> error</span><span class="pun">:</span> <span class="typ">Allowed</span><span class="pln"> memory size of </span><span class="lit">134217728</span><span class="pln"> bytes exhausted </span>
To fix this issue you need to increase memory allocated to php. To increase memory limit you have to set memory_limit parameter to 256M or 512M in php.ini file.
Or for quick solution add memory limit in the command :
php -d memory_limit=1G bin/magento setup:di:compile
php -d memory_limit=1G bin/magento setup:static-content:deploy
Hope so it will help you.