php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27853 Problems allocating memory for imageCreateFromJpeg
Submitted: 2004-04-03 10:16 UTC Modified: 2004-04-04 11:02 UTC
From: BTO at ono dot com Assigned:
Status: Not a bug Package: GD related
PHP Version: 4.3.4 OS: Linux
Private report: No CVE-ID: None
 [2004-04-03 10:16 UTC] BTO at ono dot com
Description:
------------
I have the following problem...

I wrote a script for automatically resizing and thumbnailing uploaded jpg images, the problem takes place when the script reaches the function imageCreateFromJpeg, in some cases (I don't know exactly which ones). PHP throws a message similar  to this one:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 6176 bytes) in /path/to/scripts/script.php on line XXX

Notice that the allowed memory is much bigger than the memory which is tried to allocate with only some variebles allocated (that doesn't seem logical).

Try this image http://wintop.host.sk/56280012.JPG

This bug is supposed to be solved (http://bugs.php.net/bug.php?id=25127) but it still happens to in a PHP 4.3.4 on a linux server.



Reproduce code:
---------------
http://wintop.host.sk/erasmus0304/bug.php.txt

Expected result:
----------------
OK

Actual result:
--------------
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 6176 bytes) in /path/to/scripts/script.php on line XXX

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-03 10:26 UTC] derick@php.net
Not a bug, loading this image into memory simply takes this much memory:

php -r 'echo xdebug_memory_usage()."\n"; $f = imagecreatefromjpeg("56280012.JPG"); echo xdebug_memory_usage()."\n";'
28960
7949920


as you see about 8mb.
 [2004-04-03 14:49 UTC] BTO at ono dot com
Ok, but I just don't understand why, because the image is only 124861 bytes long.
 [2004-04-03 16:03 UTC] derick@php.net
But it's 1500x1000 pixels, with using 4 bytes per pixel: red,green,blue and alpha that's already 6MB, and the GD library also has some overhead.
 [2004-04-04 11:02 UTC] BTO at ono dot com
Ok, thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 17 09:01:27 2024 UTC