Upgraded a site from 2.2.1 to 2.2.6. Prior to upgrade, I am able to compile manually using:
php -d memory_limit=4G bin/magento setup:di:compile
Or switch to Production mode using the same modifier.
However after upgrading using composer on the command line, compilation will not run, so the site is now stuck in Developer mode:
MiBPHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 2097152 bytes) in /var/www/vhosts/[redacted].co.uk/httpdocs/setup/src/Magento/Setup/Module/Di/Compiler/Config/Writer/Filesystem.php on line 40
Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors
This memory limit of 512MB is not configured anywhere on the system. PHP -i shows the memory limit to be 2G, which is correct. COMPOSER_MEMORY_LIMIT environment variable is not set, although setting it to unlimited or a higher value does not fix the problem.
This suggests to me the memory limit is being set in the Magento script itself, which would be a stupid thing for Magento to have done. But there we go.
Any ideas on how to resolve?
Update - did a search for hard-coded memory limits, and there are some, but they don't appear to be core ones which would affect compilation. Unless someone can tell me otherwise:
# grep -rnw /app -e 'memory_limit'
./code/Ess/M2ePro/view/adminhtml/templates/control_panel/info/php.phtml:26: <?php echo $this->phpSettings['memory_limit'] == -1 ? $this->__('Unlimited') : $this->phpSettings['memory_limit'] . ' Mb'; ?>
./code/Ess/M2ePro/Block/Adminhtml/Developers/Tabs/SystemRequirements.php:94: 'text' => $phpSettings['memory_limit'] == -1
./code/Ess/M2ePro/Block/Adminhtml/Developers/Tabs/SystemRequirements.php:96: : $phpSettings['memory_limit'] . ' Mb'
./code/Ess/M2ePro/CHANGELOG:89:* Fix: PHP memory_limit setting was overridden by lower value during Synchronization in some cases
./code/Ess/M2ePro/Helper/Client.php:169: 'memory_limit' => $this->getMemoryLimit(),
./code/Ess/M2ePro/Helper/Client.php:327: $memoryLimit = trim(ini_get('memory_limit'));
./code/Ess/M2ePro/Helper/Client.php:363: if (@ini_set('memory_limit',"{$i}M") === false) {
./code/Ess/M2ePro/Helper/Module/Support/Form.php:118:Memory Limit: {$phpInfo['memory_limit']}
./code/Ess/M2ePro/Helper/Module.php:286: 'memory_limit' => [
./code/Ess/M2ePro/Helper/Module.php:293: 'value' => (float)$clientPhpData['memory_limit'] <= 0
./code/Ess/M2ePro/Helper/Module.php:294: ? 'unlimited' : $clientPhpData['memory_limit'] . ' MB',
./code/Ess/M2ePro/Helper/Module.php:333: // memory_limit is unlimited
./code/Ess/M2ePro/Helper/Module.php:334: if ($key == 'memory_limit' && $clientPhpData['memory_limit'] <= 0) {
./code/Ess/M2ePro/Controller/Adminhtml/SetupManagement/Index.php:321: $memoryLimit = trim(ini_get('memory_limit'));
./code/Ess/M2ePro/Model/Servicing/Task/Statistic.php:175: $data['php']['memory_limit'] = $phpSettings['memory_limit'];
./code/Moogento/PickPack/lib/mpdf/mpdf.php:1712: <span id="box5">0</span> ' . ini_get("memory_limit") . '<br />
./code/Moogento/PickPack/lib/mpdf/mpdf.php:1718: <span id="box6">0</span> ' . ini_get("memory_limit") . '<br />
./code/Moogento/PickPack/lib/mpdf/mpdf.php:1754: $mem = $m * 100 / (ini_get("memory_limit") + 0);
./code/Moogento/PickPack/lib/mpdf/mpdf.php:1755: $mem2 = $m2 * 100 / (ini_get("memory_limit") + 0);
./code/Moogento/PickPack/lib/mpdf/utils/font_collections.php:21:ini_set("memory_limit","256M");
./code/Moogento/PickPack/lib/mpdf/utils/font_dump.php:28:ini_set("memory_limit","512M");
./code/Moogento/PickPack/lib/mpdf/utils/font_coverage.php:20:ini_set("memory_limit","256M");
./code/Moogento/PickPack/lib/mpdf/utils/font_dump_OTL.php:24:ini_set("memory_limit","512M");
./code/Moogento/PickPack/lib/mpdf/utils/font_names.php:22:ini_set("memory_limit","256M");
./code/Moogento/PickPack/lib/mpdf/examples/example_test.php:10:ini_set("memory_limit","256M");
./code/Moogento/PickPack/lib/mpdf/examples/example33_unicode_supplementary_planes.php:2:ini_set("memory_limit","128M");
./code/BoostMyShop/SmartPrice/Helper/Catalog/Category.php:3:ini_set('memory_limit', '1G');
./code/BoostMyShop/SmartPrice/Helper/Catalog.php:3:ini_set('memory_limit', '1G');
./code/BoostMyShop/SmartPrice/Controller/Adminhtml/Catalog/Download.php:3:ini_set('memory_limit', '1G');
./code/BoostMyShop/SmartPrice/Controller/Adminhtml/Seller/TokenInput.php:3:ini_set('memory_limit', '512M'); //TODO : move this ?
Has anyone got any suggestions on this? PHP on the command line show a current memory limit of 8GB, running Magento compiler complains about a memory limit of 512MB, which is not set anywhere I can see.
Only an issue since upgrading to 2.2.6.
Have you checked your .htaccess file and confirmed that there is no php_memory that makes the change there?