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

<p>I added the fix Brad mentions + another config line:</p>

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

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

<p>This was before adding the <code>'generateTransformsBeforePageLoad' =&gt; true,</code> line to our config, I haven't tested removing this setting after adding that to our config. </p>

<p>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.</p>

CC BY-SA 3.0
2017-02-12T00:40:11.947Z
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
CC BY-SA 3.0
2017-02-13T15:57:43.267Z
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
CC BY-SA 3.0
2017-02-11T21:33:59.113Z
2017-02-11T21:33:59.113Z
Nate Beaty
<p>Wondering if anyone else has had issues with memory and a large amount of image transforms.</p>

<p>I <em>seems</em> 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.</p>

<p>Possibly related: <a href="https://stackoverflow.com/questions/9993085/php-imagick-memory-leak/12835966#12835966">https://stackoverflow.com/questions/9993085/php-imagick-memory-leak/12835966#12835966</a></p>

CC BY-SA 3.0
2015-11-20T18:53:43.533Z
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
CC BY-SA 3.0
2015-11-20T22:52:42.817Z
2.4 - you think 2.5 addresses it?
Tim Kelty
CC BY-SA 3.0
2015-11-20T23:28:05.853Z
There are definitely changes around Imagick and transforms in 2.5, would be worth testing.
Brad Bell
<image-transforms><tasks><memory>
Possible memory leak - GeneratePendingTransforms/ImageMagick
# Possible memory leak - GeneratePendingTransforms/ImageMagick

(Asked by: username_0 on 2015-11-20)

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>

**Tags:** image-transforms, tasks, memory
> **Comments:**
> **username_1**: 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.  
> **username_0**: 2.4 - you think 2.5 addresses it?  
> **username_1**: There are definitely changes around Imagick and transforms in 2.5, would be worth testing.  

---

## 1 answers

### Answer by username_2 on 2017-02-11. Score: 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.

> **Comments:**
> **username_3**: 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.  
> **username_2**: 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.  

---

