Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-12T00:40:11.947Z
Answers.Text: 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.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-13T15:57:43.267Z
Answers.Text: 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.
Answers.UserDisplayName: Nate Beaty
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-11T21:33:59.113Z
Answers.LastActivityDate: 2017-02-11T21:33:59.113Z
Answers.UserDisplayName: Nate Beaty
Body: <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>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-11-20T18:53:43.533Z
Comments.Text: 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.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-11-20T22:52:42.817Z
Comments.Text: 2.4 - you think 2.5 addresses it?
Comments.UserDisplayName: Tim Kelty
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-11-20T23:28:05.853Z
Comments.Text: There are definitely changes around Imagick and transforms in 2.5, would be worth testing.
Comments.UserDisplayName: Brad Bell
Tags: <image-transforms><tasks><memory>
Title: Possible memory leak - GeneratePendingTransforms/ImageMagick
ThreadText: # 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 username_1 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.  
  
  ---
  
  