Magento Asked by Khushbu Mehta on November 8, 2021
I have error when i add module..
Please re-run Magento compile command
so i run below command but also display error that below when run command from root,
php magento setup:di:compile
Compilation was started.
%message% 0/7 [>---------------------------] 0% 1 sec 37.0 MiB%message% 0/7 [>
---------------------------] 0% 1 sec 37.0 MiBProxies code generation... 0/7 [
>---------------------------] 0% 1 sec 37.0 MiB
Proxies code generation... 1/7 [====>-----------------------] 14% 47 secs 43.5
MiB
Repositories code generation... 1/7 [====>-----------------------] 14% 47 secs
43.5 MiB
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate
24 bytes) in D:xampphtdocslinsenweltvendorzendframeworkzend-codesrcScan
nerFileScanner.php on line 36
How to fix ?
If you are using WAMP, the folder C:wamp64binphpphp<your-version>
contains two php ini files: php.ini
and phpForApache.ini
Look for memory_limit
option and set to afford your needs, I set mine to 9999M in both files.
Hope it helps
Answered by Flávio Santos on November 8, 2021
I use Plesk and I solved the issue run next command :
-bash-4.2$ /opt/plesk/php/7.3/bin/php -d memory_limit=3G bin/magento setup:di:compile
Note than 7.3 is my PHP release, instead you should apply your current PHP release.
Answered by Juan Ignacio on November 8, 2021
I've had the EXACT same issue. It's a combination of RAM and PHP version. I have to call /opt/plesk/php/7.0/bin php -d memory_limit=3G bin/magento setup:di:compile (or flush, etc)
Answered by Mollask on November 8, 2021
67
A quick solution for memory limit in Magento 2 command is directly adding memory limit inside command.
For Compilation command,
php -dmemory_limit=5G bin/magento setup:di:compile
For Deployment
php -dmemory_limit=5G bin/magento setup:static-content:deploy
You can change as per 5G to max if issue not resolve.
Answered by Alauddin Forhad on November 8, 2021
I have got solution for my question. For memory exhausted error, we have to add memory limit for compile code.
php -dmemory_limit=4G bin/magento setup:di:compile
Hope it will help someone in future.
Answered by Khushbu Mehta on November 8, 2021
for M2 add memory limit via ssh with below command.
for compile command : php -dmemory_limit=5G bin/magento setup:di:compile
for deploy command : php -dmemory_limit=5G bin/magento setup:static-content:deploy
you can increase value 5G if issue not solved.
Answered by Anas Mansuri on November 8, 2021
If you are facing this issue in the cli, please try This command:
php -dmemory_limit=8G bin/magento setup:upgrade
Answered by Hiren Kapuriya on November 8, 2021
Compilation using "-d memory_limit=5G" is not a wise decision. It's a temporary solution which may get affected during the process of Mode Switching i.e from Developer to Production. This time the system compiles the code without this logic "-d memory_limit=5G" which throws the error.
It's a better option to fix this error at this stage. To fix this, open php.ini and increase the memory_limit by 1024M and execute compile command php bin/magento setup:di:compile
Check this: https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors
This time it should work
Answered by zuber bandi on November 8, 2021
User the following line after
php/bin magento -d memory_limit=5G s:d:c
for your compilation code. This is due the allowed memory limit to the php. But after allowing the memory limit in the command this will remove the error and your compilation and other commands will run without any error. Just add this
-d memory_limit=5G
in every command as you seen in the example above.
Upvote if you found my answer useful.
Answered by Manish Kumar on November 8, 2021
If you are using PHP >= 5.3.0 and you used the Magento 2.1.x and above, then after you run composer install
, two files will be created in your root directory and your pub directory named .user.ini
Edit those files to override your PHP.ini settings, in this case is the memory_limit
; Set PHP memory limit to 768M which already enough for compilation tasks
memory_limit = 768M
max_execution_time = 18000
If you are using Apache, you will need to care the files inside root directory only, not the /pub
one and vice versa if you are using engineX (nginx)
Hope it helps.
Answered by Toan Nguyen on November 8, 2021
This situation can be tricky to debug since if you just to
php -r "echo ini_get('memory_limit').PHP_EOL;"
it shows the memory limit for the PHP in your path, which might be fine. But the magento script (bin/magento) uses the preamble
#!/usr/bin/env php
so it is not necessarily using the PHP from your path! One way to track down the php.ini
file which is being used is to write a small script like this:
#!/usr/bin/env php
<?php
phpinfo();
call it getinfo
(not getinfo.php
!), make it executable, then run it like this:
./getinfo | grep php.ini
This will show you the ini file you need to change. In that file, change the configuration value memory_limit
as suggested in other posts, to a higher value than 128M. Then save the file and check your work:
./getinfo | grep memory_limit
Answered by Scott C Wilson on November 8, 2021
php -dmemory_limit=6G bin/magento setup:di:compile
Answered by Sheshgiri Anvekar on November 8, 2021
use this 'dirty' way
php -dmemory_limit=-1 bin/magento setup:di:compile
Answered by Ansyori on November 8, 2021
A quick solution for memory limit in Magento 2 command is directly adding memory limit inside command.
For Compilation command,
php -dmemory_limit=5G bin/magento setup:di:compile
For Deployment
php -dmemory_limit=5G bin/magento setup:static-content:deploy
You can change as per 5G to max if issue not resolve.
Answered by Rakesh Jesadiya on November 8, 2021
I run into similar problem, memory limit was increased to 2Gb inside php ini file, phpinfo() file showed it was set to 2Gb. It seems Magento set memory limit manually somewhere. I increased memory limit inside file bin/magento. In first line I put this:
ini_set('memory_limit', '656M');
which made it working.
Answered by JohnyFree on November 8, 2021
You need to increase memory allocated to php. To increase memory, execute command php --ini
. Findout loaded php.ini. It should be like
Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File: /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d
Additional .ini files parsed: /etc/php5/cli/conf.d/05-opcache.ini,
Go to current loaded php.ini (/etc/php5/cli/php.ini) and findout memory_limit parameter. Increase the value against memory_limit parameter to 256M or 512M.
Answered by Amit Sachan on November 8, 2021
Looks like your cli has only 128MB of memory allocated. Increase the value to at least 256MB or 512MB if you can.
Answered by Marius on November 8, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP