[mapserver-users] memory leaks

matt matt at aruke.com
Thu May 10 21:48:55 EDT 2001


thanks again Steve,

everything is a lot more stable now that i'm not running on mod perl,
although a little slower than when mod perl first starts up and hasn't built
up a whole lot of memory.  i am still hoping for the fix, though because i'm
guessing if working right mod perl would perform better.

matt

----- Original Message -----
From: "Stephen Lime" <steve.lime at dnr.state.mn.us>
To: <matt at aruke.com>; <mapserver-users at lists.gis.umn.edu>
Sent: Friday, May 11, 2001 1:10 AM
Subject: Re: [mapserver-users] memory leaks


My guess is that the problem is related to Swig and mod_perl. I recall
seeing messages on the Swig mailing list about problems that made
Swig-based modules unusable within mod_perl. I'll drop a note to the
Swig list to see if I can get an update. You might just running as a perl
CGI (i.e. no mod_perl) and see if you see the same problems. That
would help isolate things.

Steve

Stephen Lime
Internet Applications Analyst

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> "matt" <matt at aruke.com> 05/10/01 01:50AM >>>
hi,

i'm using mapserver 3.3.011 on redhat 6.2.  i'm generating my map image
using mapscript perl module on mod_perl 1.25 on apache 1.3.9.

i'm not doing anything complicated, just grabbing a map file and generating
the image, my problem is that when i'm monitoring my memory usage increases
pretty darn fast when printing heavy maps.

i've included code that i'm using at the bottom, if anyone sees anything
obviously stupid i'd be happy to hear what it is.  i'm a cold fusion
programmer a little new to mod perl.

my goal right now is to share as much memory as possible, i've already done
a perlrequire to a script that loads mapscript and all my other modules into
the parent process,

i'm guessing my $map and $img vars are my biggest concern, is there anyway
that i can code this so that i am sharing these variables across all httpd
processes(assuming i'm not already) like my modules?

also rather than create new map objects on each request i tried

    if (!defined $map) {$map = new mapObj(file);}

but when i printed the map it had garbled data from the prviously drawn map,
is there a way to flush/clean out the image so this works?


any help would be greatly appreciated,

matt

------ here's a stripped version of my code, i call it from within an html
img tag. --------------
#!/usr/bin/perl
use mapscript;
use XBase;
require "glbLib/parse_form.pl";
require "glbLib/util.pl";

my %formdata;
%formdata = parse_form();
my @ti = localtime(time);
###### parse query string for vars ##########
my $key;
my ($lat,$lon,$zoom);
my $zm;
my $filename;
my $flvar = do_count("./","mapctr",1000);
my $mapfile;
my $numpoints = 0;
##### create a filename using time and file numbers ####

$filename =
"MS_". at ti[5]."-". at ti[4]."-". at ti[3]."--". at ti[2]."-". at ti[1]."-". at ti[0]."*".$fl
var;
$mapfile = "/usr/local/apache/htdocs/tmp/".$filename;
  foreach $key (sort keys(%formdata)){
    if ($key =~m/mlat/){
      $lat = $formdata{$key};
    }
    elsif ($key =~m/mlon/){
      $lon = $formdata{$key};
    }
    elsif ($key =~m/zoom/){
      $zoom = $formdata{$key};
    }
 }

$map = new mapObj('/usr/local/apache/perl/demo.map');

my ($CVlat,$CVlon) = latToMeter($lat);
my $latdf = $zoom * 500 * $CVlat;
my $londf = $zoom * 500 * $CVlon;
$map->{extent}->{maxx} = $lon + $londf;
$map->{extent}->{minx} = $lon - $londf;
$map->{extent}->{maxy} = $lat + $latdf;
$map->{extent}->{miny} = $lat - $latdf;
$img = $map->draw() or die('unable to draw map');

####################### draw map and save #################

$map->drawLabelCache($img);
mapscript::msSaveImage($img,$mapfile,0,0);
mapscript::msFreeImage($img);

##### read in file and stream it into page, set content type. ####

print "Content-type: image/gif\r\n\r\n";
open(FILE,$mapfile);
binmode(FILE);
@buffer = <FILE>;
foreach (@buffer){
  print $_;
}
close(FILE);
system("rm -f $mapfile");
undef $map;
############################ end ############################






More information about the mapserver-users mailing list