ID:               42356
 Updated by:       [EMAIL PROTECTED]
 Reported By:      myteamz at rogers dot com
 Status:           Bogus
 Bug Type:         Reproducible crash
 Operating System: Windows XP SP2
 PHP Version:      5.2.3
 Assigned To:      pajoye
 New Comment:

"From this, it appears there is 1 or 4 bytes for color, plus 1 byte
for
something else.  This should be in the docs"

I know exactly how much memory a GD image uses. I can't say (well I can
but not easily) how much memory is used by a PHP resource, its variable,
the code used to initialize it.

Not a bug > bogus remains.


Previous Comments:
------------------------------------------------------------------------

[2007-08-21 19:39:12] myteamz at rogers dot com

On looking further, both imagecreate andimagecreatetruecolor were
working, and use different amounts of memory.  However, the amounts are
different than 4 bytes in both cases.

For imagecreate, 2 bytes (+marginal overhead) are allocated.
For imagecreatetruecolor, 5 bytes (+about .15 per pixel) are
allocated.

These were calculated using the following script;

<?php
    for ($i=0;$i<2;$i++) {
        println("iteration = $i");
        $mUsed = memory_get_usage(true);
        $mPeak = memory_get_peak_usage(true);
        println(" $mUsed, $mPeak");
        
        $xSize=8192;
        $ySize=1024;
        if ($i==0) $im = imagecreate($xSize,$ySize);
        else $im = imagecreatetruecolor($xSize,$ySize);
        
        $mUsed2 = memory_get_usage(true);
        $mPeak2 = memory_get_peak_usage(true);
        println(" $mUsed2, $mPeak2");
        $iUsed = $mUsed2-$mUsed;
        $perPixel = $iUsed/($xSize*$ySize);
        println(" incremental memory - $iUsed ($perPixel per pixel)");
        
        imagedestroy($im);
        
        $mUsed3 = memory_get_usage(true);
        $mPeak3 = memory_get_peak_usage(true);
        println(" $mUsed3, $mPeak3");
        println;
    }
    
function println($text) {print("$text\n<BR>");}
?>

>From this, it appears there is 1 or 4 bytes for color, plus 1 byte for
something else.  This should be in the docs.

Consider the item closed.

------------------------------------------------------------------------

[2007-08-21 17:44:23] [EMAIL PROTECTED]

"When I change my call to use imagecreatetruecolor instead of
imagecreate, the memory usage is exactly the same, suggesting the PHP
imagecreate is calling the GD gdImageCreateTrueColor and reducing the
available image size by a factor of 4.  If this is the case, why?"

That's not the case. You consider the values returned by the memory
info functions are accurate, they are not.

"This implies that the default max image GD can handle (for height of
1024) is about 32M/1024/4 = 8K."

Completely wrong, you are looking at the wrong place to fix your
problem. If you have doubt about the cause (memory limit), try to run
your script (and only what you show here) using CLI (command line).


------------------------------------------------------------------------

[2007-08-21 15:25:35] myteamz at rogers dot com

With understanding of how much memory GD uses per pixel (4 bytes), I am
able to scale image request size to fit in memory, but result is that
image is not large enough to build tree.

When increasing memory_limit to 128M, I still run into 32M limit, and
upon looking further, it appears that default Apache Windows distro is
built with MAX_PROCESS_SIZE = 32M.

This implies that the default max image GD can handle (for height of
1024) is about 32M/1024/4 = 8K.

When looking further into GD documentation, there is a reason why I am
using imagecreate instead of imagecreatetruecolor.  The GD docs say
gdImageCreate(sx, sy) has a 256 color limit, or 1 byte per pixel, while
gdImageCreateTrueColor(sx, sy) has "an essentially unlimited number of
colors" - presumably 32 bit or 4 bytes per pixel.

When I change my call to use imagecreatetruecolor instead of
imagecreate, the memory usage is exactly the same, suggesting the PHP
imagecreate is calling the GD gdImageCreateTrueColor and reducing the
available image size by a factor of 4.  If this is the case, why?

------------------------------------------------------------------------

[2007-08-21 14:31:11] [EMAIL PROTECTED]

Your image takes 13770*990*4 bytes, which is ca. 54mb. That doesn't fit
in 32 mb memory limit.

------------------------------------------------------------------------

[2007-08-21 14:21:14] myteamz at rogers dot com

You have ignored the other submitted info that shows (via call to
memory_get_usage(true)) that the memory in use is actually less than
7M.

Either the function call is reporting incorrect values, or there is a
problem in the memory manager believing 32M is in use.

I have subsequently added a call to memory_get_peak_usage(true), and it
reports the same value as memory_get_usage(true), indicating I have come
nowhere near using 32M.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/42356

-- 
Edit this bug report at http://bugs.php.net/?id=42356&edit=1

Reply via email to