I keep running into this error, uploading an image that while large in dimensions, is only 300kb. I searched the forums and tried setting my PHP.ini file's memory setting to 128MB, 256MB, 1024MB, whatever, and still get this error regardless:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 30212 bytes) in site\includes\image.inc on line 308

How can I defeat this problem?

Comments

litwol’s picture

sometimes its worth rebooting your system. i run a windows server and for the life of me sometimes i cnat get rid of the exhausted memory error until i reboot the machine. or in the least reboot the whole server software (not the OS, just apache and such)

Sometimes something interesting appears on http://litwol.com

mokargas’s picture

Thanks for the suggestion

Just tried rebooting apache and the server machine (2GB DDR 667 on it), no luck :(

VM’s picture

after changing memory_limit

are you then running phpinfo() to make sure the changes are actually sticking ?
___________________________________________________________________________________________________
The search tool on Drupal.org really does work. This message has been brought to you by the letter X. Thanks for watching! : )

mokargas’s picture

I managed to solve the problem, there was a strange character inside the memory_limit line

I have another problem now tho, "The connection was reset" if I try upload more than 1 file at once with Image Import, locally, with each file ~30kb :/

mokargas’s picture

Ok fixed this too, what it was, was if the original image < than the dimensions set for the "preview" derivative image, the connection gets reset, so instead of 640x640 for the preview I set 640x480 (since the images that forced the reset behaviour had heights less than 640pixels)

pbarnett’s picture

Hi.

I looked at the source; see below :-

302  function image_gd_open($file, $extension) {
303   $extension = str_replace('jpg', 'jpeg', $extension);
304   $open_func = 'imageCreateFrom'. $extension;
305   if (!function_exists($open_func)) {
306     return FALSE;
307   }
308   return $open_func($file);
309 }

which suggests that it's the GD library asking for a lot of memory. What does the site status report say about your GD library?

Pete.

tm’s picture

i ran into something similar elsewhere. someone had mentioned drupal's 50% "sanity-check", so i made the memory_limit what i thought is should be, then made post_max_size double that, and restarted the web server. sounds strange, but it worked.

hope you find your solution.

doc2@drupalfr.org’s picture

Sorry Todd, could you explain that a bit more? I found a similar yet unsolved topic there: http://drupal.org/node/206851 . But I think we're closer to an answer here. So...

someone had mentioned drupal's 50% "sanity-check", so i made the memory_limit what i thought is should be

1- What does drupal's 50% "sanity-check" means?

then made post_max_size double that, and restarted the web server.

2- Did you just double the post_max_size, or did you make it double the memory_limit?

Thank you!

tm’s picture

sanity check discussion: http://drupal.org/node/104220 - don't know the status of the backport

sorry about the funky statement: i made the post_max_size double the upload_max_filesize. my memory_limit is way beyond that (post_max_size + system overhead, sessions, etc)!

doc2@drupalfr.org’s picture

I get the point, slowly. Thank you for this answer.

I think there could be a post/book page that would show (the server's) memory allocations as a hierarchical tree (:A:) according to their dependencies so that we know how-to configure them and within which file (:B:) to do so.

Such as... NB.: I'm not sure at all about this tree, this is just given as (bad) layout example!

::A:: Memory allocation maps

  • (1) memory_limit :
    • (2) post_max_size :
      • (2.1) upload_max_filesize
      • (2.x) post_related_threads?
    • (3) system overhead :
      • (3.x) ...
      • (3.x+1) system_overhead_related_threads?
    • (Y)...? :
      • (Y.x) ...
      • (Y.x+1)..._related_threads?

... completed with config hints like:

::B:: Config Infos:

- You can config (1) according to http://drupal.org/node/29268 . NB.: The following advise is just given as a (false) advise example! (1) should be taller than all dependent threads: (1) > (2)+(3)+(Y).
- (2) should be twice (2.1). Or calcuted more precisely according to...
- (Y.x+1) can be calculated like this: (...) . See also this topic...
- ...

michellepurestock’s picture

We are able to upload 14 mb files of video but not anything over 1mb for images.

I have set the post_max_size to 100mb and the memory limit to 40mb and still get the weirdness.

I am not a programmer nor understand the above so I guess we are stuck.

tm’s picture

assuming you are using the image module: not sure if this is core-specific, but in the d5 version, image module has its own settings/limitations (look under administer > site configuration > image).
- the system setting is your global "cap"
- - the file uploads settings under that
- - - the image module settings fit somewhere under that.

wow, that's a lot of nested settings...

michellepurestock’s picture

Hey we are in d5. Using image module. version

administer > site configuration > image set to 3mb

In file upload>settings set to 100mb per upload
In file upload>settings set to 5000mb per user

php.ini memory limit is set to 40mb

I get this error when trying to upload anything over 1mb

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 11392 bytes) in /home/purestoc/public_html/includes/image.inc on line 326

I went in and cleaned up modules that we are not using. I don't have more than 10 users on the site at once and the server load at my webhost looks good.

This is a new problem BTW.

michellepurestock’s picture

Okay, as the initial starter of this thread stated. This has nothing to do with total file size ie 1mb or 2 mb but with the image dimensions themselves.

I tried to upload a image that was 2848 x 2134 and 1.3 mb no dice get the Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 11392 bytes) in /home/purestoc/public_html/includes/image.inc on line 326

Take the same image and make it 2000 x 1499 and 1.8 mb and magic!! Uploads fine.

So since I have no restrictions set on actual image dimensions how do we get around this one?

tm’s picture

so, in the image settings (administer > site configuration > image), what is your max image dimensions? if one dimension of an image (x or y) exceeds, it might blow up trying to deal with it.

jscoble’s picture

Are you sure your changes to the memory limits in PHP are taking affect? The error information you provide shows that the PHP memory limit is currently at 32MB. 40MB would be 41943040 bytes.

Have you tried another image library to see if that helps? IIRC, GD2 isn't the most memory efficient image library.

michellepurestock’s picture

Hi,

I get the error code with the size of 33554432 no matter what the php memory limit is set to in php.ini.

I haven't tried another image library.

Also have set dimensions to 0 meaning, we allow any x and y dimension.

jscoble’s picture

From the path that you posted earlier, it appears your on a shared server. Is this the case? You can ask the hosting company to up the memory limit for you, add a 'php_value memory_limit' setting in your .htaccess, or conditionally change it in your scripts.

If you have control of your server then you need to restart apache to see the memory limit changes.

michellepurestock’s picture

Yes we are on a shared server. I will ask them up the memory limit. Thanks for the tip.

mabar207’s picture

I have the exact same problem. I tried to use FTP and it crashed my whole website, I tried mass import, and again it crashed my whole website and then I tried to add 1 image at a time and it crashed but only the upload and my website was fine....

It is always the same error message: includes/image.inc on line 326

I'm using the latest release, and I uninstall and reinstall the module billion times. hehehe

Also, something funny happened, I tried uploading a picture, a .jpg of 936kb, 2272x1704 and it crashed. I converted the picture in a .gif with GIMP, I uploaded the new picture and it worked!?? So that makes me believe it's neither a problem with the size nor the dimension...

Anyone has an idea of what I should do from here to get around this without converting all my pictures in .gif?

Thanks!

Matt

morimori’s picture

Hi,

I ran into a similar problem (but local installation using MAMP and Drupal 6.11):
http://drupal.org/node/430670

Changing the memory limit in the .htaccess and settings.php files to 256MB solved the problem, which does not make much sense to me with a file-size of about 1MB.