Jump to content


[solved] Fatal Error: Memory Size Exhausted


  • You cannot reply to this topic
6 replies to this topic

#1 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 25 March 2006 - 02:44 PM

Copied from a message in the snippet support forum:

martin.kuna, on Mar 25 2006, 02:24 PM, said:

...

Another problem I have is when uploading file larger than about 300 kB. I always get message like this:

Quote

Fatal error: Allowed memory size of 10485760 bytes exhausted (tried to allocate 6400 bytes) in /data/www/mydomain.com/www/index.php(524) : eval()'d code on line 163

The line 163 is the bold one below:
function createthumb($filename,$path_to_gal,$max_thumb_size,$prefix="") {
// Create thumbnails
$src=imagecreatefromjpeg($path_to_gal.$filename);
$src_size = getimagesize( $path_to_gal.$filename );

The file is uploaded but it's not resized and a thumbnail isn't created as well.


#2 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 25 March 2006 - 03:03 PM

I would guess the problem is that the pixel dimensions of the file are too large.

The imagecreatefromjpeg function creates a bitmap image in memory from the jpeg file. For every pixel in the image it will use at least 3 bytes, plus some overhead - so an image from a 6Mpixel camera will require more than 18Mbytes just to render the image. This is more than most hosts will allow for a PHP process, so it fails. Even an image from a 3Mpixel camera will require 9MBytes for the image - once it starts to process the picture it will need more memory, so this too will fail if the memory limit is 10Mb (which seems to be fairly common).
If this load fails, it won't resize the image or create a thumbnail, since processing is aborted. (even if the error were treated as a warning, it still couldn't sensibly continue, as there is no image to process to generate the new files).
Its the pixel size that is the problem, not the number of bytes in the jpeg file.

You will need to reduce the pixel size of the image (preferably from the original file rather than the jpeg file you produced for upload).

Edited by mikef, 25 March 2006 - 03:12 PM.


#3 churchyard

    Etomite Forum Fan

  • Member
  • Pip
  • 65 posts

Posted 25 March 2006 - 03:11 PM

if there is some jpg that has more than 300 kB, how it is large? 8000px : 4000px ?

i found one jpg (1134 x 834) -> 150 kB
Are you sure you want to add on your gallery image in 1134 x 1668 resolution?

#4 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 25 March 2006 - 03:25 PM

churchyard, on Mar 25 2006, 03:11 PM, said:

if there is some jpg that has more than 300 kB, how it is large? 8000px : 4000px ?
i found one jpg (1134 x 834) -> 150 kB
There is no way to even make a reaasonable guess at the pixel dimensions of an image in a jpeg file based just on the file size.
Firstly, the 'quality' settings used during conversion have a huge impact on size.
Secondly, the file may include an ICC profile (to accurately define colour mapping), and these can be large.
Thirdly the file may contain other data based on either EXIF or IPTC standards (or both).

churchyard, on Mar 25 2006, 03:11 PM, said:

Are you sure you want to add on your gallery image in 1134 x 1668 resolution?
Etogal can do size reduction for you, as long as the initial image isn't too big for memory. You can set a maximum pixel size in the snippet call, and it will shrink to this, so you don't have to resize it yourself. Etogal will only save the shrunk image, plus the thumbnail, so the only penalty is the amount of time it takes you to upload the original file.

#5 churchyard

    Etomite Forum Fan

  • Member
  • Pip
  • 65 posts

Posted 25 March 2006 - 04:06 PM

even it is better to resize it myself, i can make some cuts and so on

#6 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 25 March 2006 - 04:13 PM

churchyard, on Mar 25 2006, 04:06 PM, said:

even it is better to resize it myself, i can make some cuts and so on
Yes, but that takes longer!
For the lowermosswood site, its not just me uploading the files, but other volunteers; for them, the easier the better, unless they happen to also be photographers!
For the efikim site, its unlikely that I'd leave etogallery to resize my main images.

#7 churchyard

    Etomite Forum Fan

  • Member
  • Pip
  • 65 posts

Posted 25 March 2006 - 05:01 PM

ok, great





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users