Cms: On Update — "Allowed memory size of X bytes exhausted"

Created on 19 Jul 2017  Â·  20Comments  Â·  Source: craftcms/cms

Description

I am unable to update Craft via the admin tool on a local MAMP server. The CMS only has a couple placeholder entries made within the CMS and the element API is installed.

Status: Internal Server Error

Response: <pre>PHP Fatal Error &#039;yii\base\ErrorException&#039; with message &#039;Allowed memory size of 268435456 bytes exhausted (tried to allocate 110592 bytes)&#039; 

in /Users/bryantwells/Sites/verdes/verdes-api/vendor/composer/composer/src/Composer/Util/RemoteFilesystem.php:386

Stack trace:
#0 [internal function]: yii\base\ErrorHandler-&gt;handleFatalError()
#1 {main}</pre>

My PHP's memory_limit was set to 128M, upped to 256M and saw no change.

Steps to reproduce

  1. Basic "update" command through the utilities panel

Additional info

  • Craft version: 3.0.0-beta.21
  • PHP version: 7.0.8
  • Database driver & version: MYSQL 5.5.42
  • Plugins & versions: Element API 1.6.0
bug

Most helpful comment

Quick update – issue here is that Composer takes up a ton of time/memory when updating dependencies. We’re working on improving that in two ways:

  1. The next Craft CMS update will stop using Composer to install Craft’s JS dependencies, which reduces Craft/Yii’s dependency count by 17, and removes Craft’s reliance on http://asset-packagist.org.

  2. We are building our own Composer repository (a la Packagist) specifically for Craft, plugins, and their dependencies, meaning we will be able to disable http://packagist.org altogether. In our testing we’ve found that this will drastically reduce the memory/time footprint of the new Composer-based updater.

All 20 comments

Was that the whole stack trace for the error? If you don't mind sharing your craft/storage/logs files publicly, could you zip them up and attach them here?

Within the response rendered in the viewport, in dev mode, yes — that was the complete stack trace. Attaching logs below...

logs.zip

Quick update – issue here is that Composer takes up a ton of time/memory when updating dependencies. We’re working on improving that in two ways:

  1. The next Craft CMS update will stop using Composer to install Craft’s JS dependencies, which reduces Craft/Yii’s dependency count by 17, and removes Craft’s reliance on http://asset-packagist.org.

  2. We are building our own Composer repository (a la Packagist) specifically for Craft, plugins, and their dependencies, meaning we will be able to disable http://packagist.org altogether. In our testing we’ve found that this will drastically reduce the memory/time footprint of the new Composer-based updater.

We haven’t seen many problems with Composer memory usage ever since 3b88277f, so going to close this.

@brandonkelly I'm getting this issue cropping up again locally every time I try to update Craft. I emailed with @angrybrad and he suggested upping the memory_limit of 128M. I increased it to 512M and I am still getting the error. Here is the error output:

Fetching available updates ... done
Performing 4 updates:

    - craft 3.3.12 => 3.3.13
    - simplemap 3.7.0 => 3.7.1
    - retour 3.1.26 => 3.1.27
    - seomatic 3.2.28 => 3.2.29

Backup the database? (yes|no) [yes]:yes
Backing up the database ... done
Performing update with Composer ... PHP Fatal Error 'yii\base\ErrorException' with message 'Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes)'

in /site_folder/vendor/composer/composer/src/Composer/DependencyResolver/RuleWatchGraph.php:52

Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}

Here is my application info:

PHP version: | 7.3.9
Platform OS: Darwin 19.0.0
MySQL: 5.7.27
Image driver & version: GD 7.3.9
Craft version: Craft Pro 3.3.12
Yii version: 2.0.21
Twig version: 2.12.1
Guzzle version: 6.3.3
Imagine version: 1.2.3-dev

Any help you could provide would be much appreciated.

@jdsimcoe Do you have the phpMaxMemoryLimit setting set by chance?

@brandonkelly @jdsimcoe 1610612736 is 1.6G or 1600M. Are you sure you're editing the correct php.ini file?

@brandonkelly @angrybrad In the CP it shows my memory_limit as 512M:

image

Since I'm running on Homebrew I've edited the php.ini file in /usr/local/etc/php/7.3/php.ini. In my config/general.php I have maxUploadFileSize=> 268435456 but no phpMaxMemoryLimit set.

PHP could be using a different php.ini file for the CLI. Try running this to find out:

php -i | grep 'Configuration File'

@brandonkelly It is only using the one:

> php -i | grep 'Configuration File'
Configuration File (php.ini) Path => /usr/local/etc/php/7.3
Loaded Configuration File => /usr/local/etc/php/7.3/php.ini

@angrybrad I just tried this on a small extension update and I said no to DB backup. Here is the output:

❯ ./craft update all
Fetching available updates ... done
Performing one update:

    - embeddedassets 2.1.0 => 2.1.1.1

Backup the database? (yes|no) [yes]:no
Skipping database backup.
Performing update with Composer ... PHP Fatal Error 'yii\base\ErrorException' with message 'Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes)'

in /site_folder/vendor/composer/composer/src/Composer/DependencyResolver/RuleWatchGraph.php:52

Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}

Also a received a similar error on a different machine:

❯ ./craft update all
Fetching available updates ... done
Performing one update:

    - embeddedassets 2.1.0 => 2.1.1.1

Backup the database? (yes|no) [yes]:no
Skipping database backup.
Performing update with Composer ... PHP Fatal Error 'yii\base\ErrorException' with message 'Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes)'

in /site_folder/vendor/composer/composer/src/Composer/DependencyResolver/Solver.php:220

Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}

The first was in RuleWatchGraph.php and the other with Solver.php.

@jdsimcoe Fixed in https://github.com/craftcms/cms/commit/df40f585cef3d7e47f811f73b08d9d71bbc9c9b2 and will be included in the next 3.3.14 release.

This is great to hear! Thanks so much for bearing with me @angrybrad. Also thanks for not getting "angry".

P.S. pardon my super lame attempt at a pun.

This is great to hear! This has happened for me locally w/ same setup (7.3 via homebrew) for a while, causing it to sit for a loooong time after running ./craft update all before barfing out that memory error, and requiring a composer update to finish up. Would love for that to stop happening.

I'm still seeing this issue in Craft 3.3.18.4 when trying to install a plugin from the Plugin Store. I'm running a Craft 3 development site using MAMP Pro on macOS Mojave, with my php.ini allowing for a memory limit of 256MB (I've also tried 512 and 1024 to no avail). I'm trying to install the Imager (aelvan/imager) plugin and I'm getting the following error:

Status: Internal Server Error

Response: <pre>PHP Fatal Error &#039;yii\base\ErrorException&#039; with message &#039;Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes)&#039;

in /Users/patrick/Development/WEBSITE_HERE/vendor/composer/composer/src/Composer/DependencyResolver/GenericRule.php:36

Stack trace:
#0 [internal function]: yii\base\ErrorHandler-&gt;handleFatalError()
#1 {main}</pre>

I was able to install composer and run composer require aelvan/imager from Terminal, and the installation was successful.

Did you capture the errors after changing memory_limit to verify that the max bytes in those errors were not also 268435456 ?

Did you capture the errors after changing memory_limit to verify that the max bytes in those errors were not also 268435456 ?

Actually, if I remember correctly, the also said the same even after adjusting the limit a few times.

If that’s the case, then either you didn’t edit the right php.ini file, or the PHP server wasn’t rebooted, which needs to happen before the changes will take effect.

I'm also getting this error when trying to update Craft through the backend.

Status: Internal Server Error

Response: <pre>PHP Fatal Error &#039;yii\base\ErrorException&#039; with message &#039;Allowed memory size of 268435456 bytes exhausted (tried to allocate 4096 bytes)&#039;

in /Users/jason/Sites/filmstreams/craft/vendor/composer/composer/src/Composer/DependencyResolver/RuleSetGenerator.php:126

Stack trace:
#0 [internal function]: yii\base\ErrorHandler-&gt;handleFatalError()
#1 {main}</pre>

This is happened when trying to upgrade from Craft 3.4.3 to 3.4.5.

My memory_limit in PHP Info is 256M

My composer file was updated to reflect the changes, so simply deleting the composer.lock file and running composer install in terminal got me up-to-date.

Ended up resolving this by reinstalling my entire valet setup.

Was this page helpful?
0 / 5 - 0 ratings