Memory allocation problem (imagecreatefromjpeg) ?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I have the following code in my php script :

$fhSrc = imagecreatefromjpeg($srcFile);

This cause me the following error : Fatal error: Allowed memory size
of 8388608 bytes exhausted (tried to allocate 4800 bytes).

I read that I should increase the memory allowed php. Not sure.
This script works fine on a Windows 2000/Apache/php4 machine but not
on a Fedora Linux/Apache/php4 machine. The configuration of php for
both computer is the same.
The gd version is 2.0.15 on Linux and 2.0 on Windows.

$srcFile is valid jpeg image of 900kb (2400x1200px). If I check the
memory use by the script just before calling imagecreatefromjpeg I get

So it seems that imagecreatefromjpeg allow too much memory on Linux.

Any idea ?


Re: Memory allocation problem (imagecreatefromjpeg) ?

Olivier wrote:
Quoted text here. Click to load it

There was a similar problem just few days ago :)

Quoted text here. Click to load it

Even if your image was 8bit (which it isn't), you'd need 2.74MB to
load it into memory. But JPEGs are 24bit, so you actually need 8.22MB
to load it, which is higher than the max. memory setting on your Linux
box, which is set to only 8MB. I believe you have higher setting on
your Windows box (or it is disabled alltogether).

Quoted text here. Click to load it

Nope. Size of image in memory is much larger than the filesize because
JPEG-files are packed. The size of the file does not correlate with
the memory required to open it.

Markku Uttula

Site Timeline