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:
Your image takes 13770*990*4 bytes, which is ca. 54mb. That doesn't fit in 32 mb memory limit. Previous Comments: ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ [2007-08-21 05:48:22] [EMAIL PROTECTED] "Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 13770 bytes) in C:\Program Files\Apache Software" I'm sorry but it has nothing to do with GD. imagecreate tries to allocate the memory it needs for an image but your application seems to have already used most of the available limit (32M in this case). By the way, fatal errors are not crashes or do you have a real crash? (segfault). If yes post a comment I will reopen this bug and move it to the engine category. ------------------------------------------------------------------------ [2007-08-21 01:28:22] myteamz at rogers dot com Description: ------------ I am creating a script to produce a PNG image of a chart showing common ancestors of several individuals, using the gd functionality supplied with php. After processing the input, including many calls to MySQL (version 5.0.2) all running on Apache 2.2 on Windows XP SP2, I am trying to allocate the image resource. This works for very small trees, but fails on all calls with large trees. The PHP error message is: Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 13770 bytes) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\GenChart\drawgraph.php on line 116 The offending code is: $im = imagecreate ($xsize, $ysize); Reproduce code: --------------- Lots of memory allocation/freeing is occurring in the script prior to this call. I have included several debug lines prior to the offending call, as below: $memMax = ini_get("memory_limit"); $memUsed = memory_get_usage(true); $xMax = round(30000000-intval($memUsed/$ysize),-3); $xsize = min($xMax,max($xsize,4000)); dumpData("have used $memUsed of $memMax memory"); dumpData("trying to create image of size ($xsize,$ysize)"); $im = imagecreate ($xsize, $ysize); The output, on crash, is have used 6815744 of 32M memory trying to create image of size (13770,990) Expected result: ---------------- I have changed the script to produce standard HTML output for debugging purposes, which allows me to get this info. When running as intended, with a small tree/image, the script should and does run successfully, creating an image, and returning it as a .PNG image. Running the same debug code for a small image (with no crash), the output is: have used 6553600 of 32M memory trying to create image of size (4000,690) Actual result: -------------- When running in debug mode for a large tree/image, the debug output is: have used 6815744 of 32M memory trying to create image of size (13770,990) When running as intended, the script fails and no image is returned to the browser. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42356&edit=1