[Mapserver-users] PHP undef WAS: Memory Leak? Extention

Daniel Berstein daniel.berstein@dmapas.com" <daniel.berstein@dmapas.com
Mon, 3 Feb 2003 09:42:33 -0300


Just an idea to enhance performace:

Can you build SHP from PG?

If your spatial datasource is SHP you should obtain higher map generation 
speeds, then modify your php script to instead of dynamically generation 
map images, write out a .map file for each map required, and finally invoke 
each mapserver using a batch file to generate all images.

Regards,

Daniel Berstein Z.
Jefe de Proyectos, dmapas.com
Eduardo Hyatt 583, Providencia, Santiago CHILE
*(56) (2) 222 22 60


-----Mensaje original-----
De:	Juanse [SMTP:georef@tie.cl]
Enviado el:	Viernes, 31 de Enero de 2003 15:04
Para:	mapserver-users@lists.gis.umn.edu; Lowell Filak
Asunto:	RE: [Mapserver-users] PHP undef WAS: Memory Leak? Extention

Here is cloudy, no rain, high humidity, mild, some 22?C, no electricity or
phone/internet problems envisaged, and we are at tuple 169 after 24 hours 
of
process. We really need to increase speed. All 2322 tuples must be proceed
for next monday, so to create the pdf files to print before next friday, so
the Final Report ships to santiago and is there on monday. We foresee a 31
volumenes 7000 pages long document. Uff!

We are running redhat linux apache server over a PIII 750 MHz, 256 Mb Ram,
40 Gb HD. We have asssembled PostgreSQL/GIS with Mapserver and are 
scripting
with PHP.

The spatial backend have 15 tables. 1 of 88000 tuples, and the rest between
1.000 and 10.000 tuples. All are Gist indexed.

We will try now daniel morisette system() approach, in the mean time for 
any
other guru's opinion here goes the code:

<?php

set_time_limit(0);

dl("php_mapscript.so");
function navegar(&$map,$factor,$extension,$mapa_x,$mapa_y) {
        if(is_array($extension)) {
                if(!empty($extension["minx"])
                                && !empty($extension["miny"])
                                && !empty($extension["maxx"])
                                && !empty($extension["maxy"])
                                && !empty($mapa_x)
                                && !empty($mapa_y)
                   ) {
                        $punto = ms_newPointObj();
                        $pre_ext = ms_newRectObj();

$pre_ext->setextent($extension["minx"],$extension["miny"],$extension["ma  
xx"]
,$extension["maxy"]);
                        $sal = $punto->setXY($mapa_x,$mapa_y);
                        $zoom = empty($factor) ? 1 : $factor;
                        $map->zoompoint($zoom,$punto,$map->width,
$map->height, $pre_ext);
                }
        }
}

$conexion = pg_connect("dbname=evidencia user=postgres password=pgsql");
$map = ms_newMapObj("eviden2.map");

$act = "select xmin(the_geom) as minx, xmax(the_geom) as maxx,
ymin(the_geom) as miny, ymax(the_geom) as maxy, gid from
titulosmerced_araucania where imagen is null and usurpada > 0 and gid > 0
order by gid ";
$resultado = pg_exec($conexion,$act);
for($i=0;$extension = pg_fetch_array($resultado,$i);$i++) {
    $capa = $map->getLayer(15);
    $titulo = $capa->getClass(0);
    $titulo->setexpression("\"". $extension["gid"] ."\"");

    $mapa_x = $map->width / 2;
    $mapa_y = $map->height / 2;
    navegar($map,$zoom,$extension,$mapa_x,$mapa_y);
    $img1 = $map->draw();
   $url_mapa = $img1->saveWebImage(MS_PNG, 0, 0, 0);
    $img = $map->drawScaleBar();
    $url_escala = $img->saveWebImage(MS_PNG, 0, 0, 0);
    $img = $map->drawReferenceMap();
    $url_referencia = $img->saveWebImage(MS_PNG, 0, 0, 0);
/*
    $img = $map->drawLegend();
    $url_leyenda = $img->saveWebImage(MS_PNG, 0, 0, 0);
*/
    $updt = "update titulosmerced_araucania set imagen='". $url_mapa . "',
escala='". $url_escala . "', referencia='" . $url_referencia . "' where
gid=".$extension["gid"] . "\n";
    pg_exec($conexion,$updt);
    echo $updt;
}
?>

After processing some 50 tuples, starting at 2 tuples per minute, the 
memory
is full and the process follows at less than one tuple per hour.

juanse
temuko-Chile



----- Original Message -----
From: Lowell Filak <lfilak@medinaco.org>
To: <mapserver-users@lists.gis.umn.edu>
Sent: Friday, January 31, 2003 2:09 PM
Subject: [Mapserver-users] PHP undef WAS: Memory Leak?


> I will have to forward that request back to the list for the PHP folks to
answer.
> Anyone who can help, please reply to germangutierrezg@yahoo.es .
> Thank you.
>
> The following message was sent by "Juanse" <georef@tie.cl> on Fri, 31 Jan
2003 10:40:56 -0300.
>
> > yes it is, but how to undef/close/destroyed? which command it is not in
the
> > docs.
> >
> >
> > juanse
> > temuko-chile
> >
> > ----- Original Message -----
> > From: Lowell Filak <lfilak@medinaco.org>
> > To: Juanse <georef@tie.cl>; Mapserver-Users
> > <mapserver-users@lists.gis.umn.edu>
> > Sent: Friday, January 31, 2003 10:38 AM
> > Subject: Re: [Mapserver-users] Memory Leak?
> >
> >
> > > Shot in the dark, but is there a possibility that after a map is
created
> > the mapObj is not being undef/closed/destroyed and that is the leak 
your
> > seeing?
> > > Lowell F.
> > >
> > > The following message was sent by "Juanse" <georef@tie.cl> on Fri, 31
Jan
> > 2003 10:27:27 -0300.
> > >
> > > > Hi everyone
> > > >
> > > > We have build this "mapmaker machine" scripting mapserver with php.
> > > >
> > > > The mapmaker machine need to do 2322 maps, comprised of a.- the 
map,
b
> > the
> > > > legend, c.- the reference map.
> > > > The application created the regional map (10 layers, 2 with 
thematic
> > clases)
> > > > then centers over the specified spot (center of each of 2322
polygons in
> > one
> > > > of the layers stored in postgresql).
> > > > Then mapserver render the 3 images (png) and stores the *.png files
in a
> > > > file and the file names in the speceified columns in the postgresql
> > table.
> > > >
> > > > if one check the process (top) the memory fill up after 90 spots,
and
> > then
> > > > the whole machine work very slowly (20 maps per night). At this
speed we
> > > > need more than a 100 days to finish?
> > > >
> > > > Is there any command to free mapserver from memory? Does mapserver
have
> > any
> > > > know memory leaks?
> > > >
> > > >
> > > > Juanse
> > > > temuko-Chile
> > > >
> > > >
> > > >
> > > > ---
> > > > Outgoing mail is certified Virus Free.
> > > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > Version: 6.0.445 / Virus Database: 250 - Release Date: 21/01/03
> > > >
> > > > _______________________________________________
> > > > Mapserver-users mailing list
> > > > Mapserver-users@lists.gis.umn.edu
> > > > http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> > >
> >
> >
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.445 / Virus Database: 250 - Release Date: 21/01/03
>
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users@lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.445 / Virus Database: 250 - Release Date: 21/01/03

_______________________________________________
Mapserver-users mailing list
Mapserver-users@lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users

_______________________________________________
Mapserver-users mailing list
Mapserver-users@lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users