php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41411 imagecreatetruecolor memory break?
Submitted: 2007-05-16 17:54 UTC Modified: 2008-06-17 21:19 UTC
From: eth at ethaniel dot com Assigned: pajoye (profile)
Status: Not a bug Package: GD related
PHP Version: 5.2.2 OS: Linux FC 6 2.6.18
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: eth at ethaniel dot com
New email:
PHP Version: OS:

 

 [2007-05-16 17:54 UTC] eth at ethaniel dot com
Description:
------------
I run a image thumbnail service on my server, it runs under priority of +11. It has a memory limit set to 520M.

On some images it exits with "Allowed memory size of 545259520 bytes exhausted" when I do imagecreatetruecolor(500,375). 

Memory usage details below.

Reproduce code:
---------------
if ($photo_id==2348804) error_log(memory_get_usage()." - $newX - $newY");

$newImg = ImageCreateTrueColor($newX, $newY);

if ($photo_id==2348804) error_log(memory_get_usage()." - $newX - $newY");

Expected result:
----------------
following entry in error log

[16-May-2007 19:10:27] 6451636 - 500 - 375
[16-May-2007 18:34:24] PHP Fatal error:  Allowed memory size of 545259520 bytes exhausted (tried to allocate 2000 bytes) in /data1/albums/retreive.php3 on line 427

Actual result:
--------------
I checked the memory usage right before imagecreatetruecolor and it was at 6.4M. The memory limit was set to 512M, script run under nice +11.

It crashes on imagecreatetruecolor.

But when I set the memory limit to 10000M it works ok and the code above returns.

[16-May-2007 19:10:27] 6451636 500 - 375
[16-May-2007 19:10:27] 7405476 500 - 375

As you can see, the real memory usage raised only about 1MB instead of hitting the upper limit of 500MB.

This happened only on some images. Don't know why.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-16 17:55 UTC] eth at ethaniel dot com
Sorry, I messed up when submitting the bug report. Expected and Actual results fields are to be switched places.
 [2007-05-16 18:33 UTC] tony2001@php.net
./sapi/cli/php -r 'var_dump(memory_get_usage()); $newImg = ImageCreateTrueColor(500, 375); var_dump(memory_get_usage());'
int(88476)
int(1069836)

 [2007-05-24 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-06-17 20:34 UTC] anonymous at anonymous dot com
Upgrade to 5.2.6.
 [2008-06-17 21:19 UTC] pajoye@php.net
I suppose you are uploading an image as well?

But there is no such bug in imagecreatetruecolor, really not.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 21:01:32 2024 UTC