PHP-MapScript Memory Exhaustion Error

Umberto Nicoletti umberto.nicoletti at GMAIL.COM
Mon Jul 11 07:26:02 EDT 2005


Look at php.ini: there are various options (I do not remember them
now) that set (among other things) the maximum amount of ram that a
script can use.
Try to set it to a higher value.

HTH,
UMBERTO

On 7/8/05, John Gorkos <johng at amdswireless.com> wrote:
> Gurus-
>  I am writing a PHP-MapScript script which pulls a list of points from a DB,
> and plots them on the map using multiple styles per point.  The styles are
> dynamically altered in the script to basically draw a small bar graph with 7
> bars at each map point, to reflect various health parameters of some remote
> equipment.
>  I have mad this work in perl.  Under PHP, I am allowed to add two styles per
> point, but when I add the third, I get this:
> Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate
> 75 bytes) in /var/www/html/foo.phtml
> 
> The code snippet which produces this is as follows:
> $image=$map->draw();
> 
> $meterLayer = $map->getLayerByName("Endpoints");
> $meterClass0 = $meterLayer->getClass(0);
> $rs= mssql_query ($sql, $con);
> 
> $red = array(255,255,255,225,0,150,0);
> $green = array(255,0,255,0,200,100,0);
> $blue = array(255,0,0,150,150,50,255);
> 
> while ( $row = mssql_fetch_row($rs)) {
>  for ( $i=0; $i<3; $i++ ) {
>    $meterStyle[$i] = $meterClass0->getStyle($i);
>    $meterStyle[$i]->outlinecolor->setRGB($red[$i],$green[$i],$blue[$i]);
>    $meterStyle[$i]->color->setRGB($red[$i],$green[$i],$blue[$i]);
>    $meterStyle[$i]->set('offsetx',$i*3);
>    $meterStyle[$i]->set('offsety',0);
>  }
>  $point = ms_newPointObj();
>  $point->setXY((-1)*$row[1],$row[0]);
>  $point->draw($map,$meterLayer,$image,0,$row[2]);
> }
> 
> $image_url=$image->saveWebImage();
> 
> If the "3" in the for loop above is set to 2 or 1, it works fine, but I need
> it to be an 8, which obviously fails.  More code available on request.
> 
> I am using Mapserver 2.6, PHP 5.0.4.  The machine is 64-bit Mandrake Linux
> installation on dual Xeons with 2GB of physical ram, yadda yadda.  It's a
> healthy machine, and has run this same type of code under 2.6beta3 with Perl
> Mapscript.  However, I formatted the box to switch from SuSE to Mandrake, and
> forgot to copy the perl script over before I formatted the / partition
> (insert lots of comments about backups, etc),so I'm rewriting in PHP since I
> was shamed into learning in on the #mapserver irc channel.
> 
> Anyone have any thoughts on where I'm wrong, or is this a bug?
> 
> John Gorkos
> AMDS Wireless, LLC
>



More information about the mapserver-users mailing list