2

This question already has an answer here:

I am getting the following error when image styles are being created on my Drupal 7.24 site:

mod_fcgid: stderr: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 73834563 bytes) in modules/system/image.gd.inc on line 237"

My style is doing a scale and crop down to 300x200.

I know this could be a problem with my memory limit, which is currently 128M. As this is high, this doesn't seem like an issue.

Could it be from the use of the File (Field) Paths" module for my image names?

marked as duplicate by kenorb, Adrian Cid Almaguer, No Sssweat, Scott Joudry, Krishna Mohan Mar 23 '16 at 6:14

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    Can you tell us what some min/avg/max memory usages are on your site? The Performance will give you an idea. – mpdonadio Jan 4 '14 at 16:43
  • Statistics from the start page, where the images are supposed to show up: 11.25M (max), 10.25M (avg), 990ms (max), 777.1ms (avg) – ReBa Jan 4 '14 at 16:58
5

What's the size of your image? For scale you may need roughly:

X * Y * 4 (bytes per pixel) * 2 (for source and destination image) * 2 ( to make sure there is enough RAM for computation).

Now, core can require up to 32 MB, and modules can easily double or even quadruple this. So, let's optimistically assume your core + modules only use 64MB. That leaves other 64MB. It means you can safely scale images up to 4194304px. It seems you have enough memory for 4Mpx input images. Anything larger can cause this error and it will not be anything surprising.

  • My images are of the size around 400kb, so nothing to really get close to the 64M. The size I want is 300x200px – ReBa Jan 4 '14 at 16:23
  • 2
    @ReBa there is a huge difference between the size of a file, and the size of an image itself. What are the dimensions of the source image? If 800 x 600 px then yes, it probably should work. If it's 400kB jpg file, then it may be too big pretty easily. And as far as my experience goes, target size does not significantly affect memory used to resize. Can't say exactly how GD implementation is doing it, but anyway. – Mołot Jan 4 '14 at 16:27
  • I agree with @Mołot here. The error message you are getting is when GD is trying to load the image. – mpdonadio Jan 4 '14 at 16:36
  • 1
    @ReBa And note that I made some bold assumptions. It's pretty possible that Drupal & other modules use almost all of your 128MB, leaving even less than what I assumed for my calculations. As official documentation says: "Typically 128 MB or 256 MB are found in production systems. Some installations may require much more, especially with media-rich implementations." – Mołot Jan 4 '14 at 16:44
  • I haven't had any problems with my memory limit before, and it was a 64M. So I suppose (although I can't say "know") that it shouldn't be the memory usage itself. My images are originaly around 1200x1200px (or 1200x1600px max) so in fact it's not size that's relevant. Could it be that the images are somewhat corrupt, and he's not able to track this? – ReBa Jan 4 '14 at 16:51

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