php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43757 imagecreatefromjpeg error
Submitted: 2008-01-05 05:53 UTC Modified: 2010-04-28 18:59 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:2 (66.7%)
From: xfreelancer at yahoo dot com Assigned: pajoye (profile)
Status: Not a bug Package: GD related
PHP Version: 5.2.5 OS: CentOS
Private report: No CVE-ID: None
 [2008-01-05 05:53 UTC] xfreelancer at yahoo dot com
Description:
------------
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to
allocate 26320 bytes) in /home/test.php on line 4


Reproduce code:
---------------
$ims=imagecreatefromjpeg("90-9bb2.jpg");


Expected result:
----------------
$ims should contain the jpg photo.


Actual result:
--------------
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to
allocate 26320 bytes) in /home/test.php on line 4


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-05 05:56 UTC] xfreelancer at yahoo dot com
Dear Pajoye,

I have increased the memory limit from 32Mb, to 128Mb, then to 256Mb and so on.
The bug/problem still appears.

It seems that on SOME jpeg images (which are perfectly fine) PHP is eating MY ENTIRE memory.

At the beginning I thought it's just one jpeg that generates this problem, but then I've seen the same error on different servers/configuration on our network (we have like 15 servers, located on different ISP etc.)

Please investigate the problem and do not tell me over and over again to increase the memory limit because as I've said MANY TIMES I did that already and it is clear that PHP is eating the entire memory without reason.

At the moment we already receive this error more than 50-60 times/day (we have many community websites where people are uploading their photos).

Thank you.

(I can provide full production enviroment for tests if needed)
 [2008-01-05 06:01 UTC] xfreelancer at yahoo dot com
In case you need more information about our PHP voila phpinfo():

PHP Version 5.2.5 

System  Linux xxx.xx 2.6.21-1.3194.fc7 #1 SMP Wed May 23 22:35:01 EDT 2007 i686  
Build Date  Dec 31 2007 13:26:06  
Configure Command  './configure' '--disable-all' '--with-pcre-regex' '--enable-simplexml' '--enable-libxml' '--enable-session' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-mysql' '--enable-ftp' '--with-config-file-path=/etc' '--with-freetype-dir=/usr/lib' '--with-png-dir=/usr/lib' '--with-gd' '--enable-gd-native-ttf' '--with-zlib' '--with-jpeg-dir=/usr/lib' '--with-gmp' '--with-openssl' '--with-pear' '--enable-xml' '--with-curl' '--with-config-file-path=/etc'  
Server API  Apache 2.0 Handler  
Virtual Directory Support  disabled  
Configuration File (php.ini) Path  /etc  
Loaded Configuration File  /etc/php.ini  
PHP API  20041225  
PHP Extension  20060613  
Zend Extension  220060519  
Debug Build  no  
Thread Safety  disabled  
Zend Memory Manager  enabled  
IPv6 Support  enabled  
Registered PHP Streams  php, file, data, http, ftp, compress.zlib, https, ftps  
Registered Stream Socket Transports  tcp, udp, unix, udg, ssl, sslv3, sslv2, tls  
Registered Stream Filters  string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, zlib.*  

AND

gd
GD Support  enabled  
GD Version  bundled (2.0.34 compatible)  
FreeType Support  enabled  
FreeType Linkage  with freetype  
FreeType Version  2.3.4  
GIF Read Support  enabled  
GIF Create Support  enabled  
JPG Support  enabled  
PNG Support  enabled  
WBMP Support  enabled  
XBM Support  enabled
 [2008-01-05 11:47 UTC] pajoye@php.net
Please provide an example of images causing this problem, paste a link to them here.


 [2008-01-13 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2008-01-25 14:38 UTC] kiclaw at o2 dot pl
Here are two sample images causing this problem:
http://static.geozeta.pl/content/images/S601.JPG
http://static.geozeta.pl/content/images/S602.JPG
 [2008-01-25 18:26 UTC] pajoye@php.net
33554432 means around 33MB. Your images are 2186 x 2112, each image will  use around 24MB. That lets approximatively 8-9MB for all other PHP operations. It is definitively a memory limit case and not a bug.

To confirm it, the images can be read by PHP and GD smoothly, with or without memory_limit.

The solution is to increase your memory limit to the current default 128MB (it is the default for a reason).
 [2010-04-28 18:49 UTC] rune dot waage at gmail dot com
Hi,
is the problem solved?

I see that "xfreelancer at yahoo dot com" which reported the issue had his memory limit set to 256Mb, and still the problem occured. So I don't think the last post in this thread solved his problem.

I find it strange that when PHP tries to allocate 26320 bytes, the error message tells you that you uses more then 33554432 bytes.
 [2010-04-28 18:59 UTC] pajoye@php.net
There was no bug to fix here. And the error only says what PHP was trying to allocate at this exact point, which does not mean that only this amount of memory is used.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 18:01:32 2024 UTC