Wondering if anyone else has had issues with memory and a large amount of image transforms.

I seems like perhaps memory is not being freed up between transforms. When GeneratePendingTransforms is running, that process skyrockets my CPU and memory, and just keeps climbing until it is done.

Possibly related: https://stackoverflow.com/questions/9993085/php-imagick-memory-leak/12835966#12835966

  • Is this on 2.4 or 2.5? If it's 2.4, do you see the same behavior on 2.5? If you do see the same behavior on 2.5, does it help if you try the suggested fix in the link? Would be done in craft/app/vendor/imagine/imagine/lib/Imagine/Imagick/Imagick.php in the smartResize method. The syntax would be like: $this->setResourceLimit(\Imagick::RESOURCETYPE_MEMORY, 256);, etc.
    – Brad Bell
    Nov 20, 2015 at 18:53
  • 2.4 - you think 2.5 addresses it?
    – Tim Kelty
    Nov 20, 2015 at 22:52
  • There are definitely changes around Imagick and transforms in 2.5, would be worth testing.
    – Brad Bell
    Nov 20, 2015 at 23:28

1 Answer 1


I had this same issue with an image-heavy site hosted on WebFaction w/ PHP5.6, using latest Craft 2.6.x version.

I added the fix Brad mentions + another config line:

// From http://stackoverflow.com/a/12835966
// Pixel cache max size
$this->setResourceLimit(\Imagick::RESOURCETYPE_MEMORY, 256);
// Maximum amount of memory map to allocate for the pixel cache
$this->setResourceLimit(\Imagick::RESOURCETYPE_MAP, 256);

in craft/app/vendor/pixelandtonic/imagine/lib/Imagine/Imagick/Imagick.php at line 33, at top of smartResize() function.

This was before adding the 'generateTransformsBeforePageLoad' => true, line to our config, I haven't tested removing this setting after adding that to our config.

When still in heavy development, we'd clear image asset caches and the transform queue would grow like crazy, and PHP processes would grow past 1.5gb until our host killed all of our processes. I haven't seen this issue since adding those Imagick settings.

  • Worth noting that this is technically a hack... it's not typically advised to modify anything in the /app folder. These changes could easily get wiped out the next time you update Craft.
    – Lindsey D
    Feb 12, 2017 at 0:40
  • True, and I don't usually touch core code, but this particular issue has crashed every Craft site I've built so far (all very image-transform-heavy). Worth noting that area hasn't been touched in some time, and I'm guessing isn't much of a focus now that Craft 3 is coming along. But yes, have to keep an eye on Craft updates to make sure those changes aren't wiped out.
    – Nate Beaty
    Feb 13, 2017 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.