[Mapserver-users] mapscript and XBase cause Out of memory errorand/or premature endof script headers error

Lowell Filak lfilak at medinaco.org
Fri Jan 3 15:32:32 EST 2003


I'm thinking as a quick test you could do:
system("ulimit");
or
system("unlimit");
and see if the script executes properly.
Lowell

The following message was sent by "Jonathan W. Lowe" <jlowe at giswebsite.com> on 03 Jan 2003 11:50:56 -0800.

> Thanks, Lowell.  New discoveries...
> 
> The CGI module seems to be the problem.
> 
> The following bare-bones script works perfectly when the "#use CGI;" is
> commented out:
> 
> #!/usr/bin/perl -w
> use strict;
> BEGIN { unshift(@INC, ('/usr/home/gisweb/local/lib',
> '/usr/home/gisweb/local/lib/perl5/site_perl/5.005/i386-freebsd'));}
> use mapscript;
> use XBase;
> use CGI;
> 
> my $mapfilename = "/usr/home/gisweb/gis/proj/berk/b20.map";
> my $image_path = '/usr/home/gisweb/www/docs/gis/scratch/';
> my $image_virtual_path = '/gis/scratch/';
> my $image_id = $$ . time() . ".png";
> 
> my $map = new mapObj($mapfilename) or die('Unable to open mapfile.');
> my $img = $map->draw() or die('Unable to draw map');
> binmode STDOUT;
> $img->saveImage($image_path .
> $image_id,$mapscript::MS_PNG,$map->{transparent},$map->{interlace},95);
> my $recnumb = 3;
> my $table = new XBase '/usr/home/gisweb/gis/data/berk/wa_b.dbf'
>         or die XBase->errstr;
> my @querydata = $table->get_record($recnumb);
> my $block_result = $querydata[1];
> 
> print "Content-type: text/html\n\n";
> print "<html><body>\n";
> print "XBase output:<br>\n";
> print "$block_result!\n";
> print "<p>Mapscript output:<br>\n";
> print "<img src=\"$image_virtual_path";
> print "$image_id\" border=\"1\">\n";
> print "</body></html>\n"
> 
> # --- End of ms_test5.cgi --- #
> 
> But...when run with "use CGI;" uncommented, the image is corrupt and the
> following message appears in the apache error_log:
> 
> gd-png:  fatal libpng error: Out of Memory
> gd-png error: setjmp returns error condition
> 
> When run in the command line (as "perl ms_test5.cgi"), the program also
> runs perfectly.
> 
> So, if the solution involves ulink/unlink, the shell builtin, how do I
> take advantage of that builtin command if the program is running within
> the apache/CGI environment?
> 
> Thanks again for your help,
> 
> Jonathan
> 
> On Fri, 2003-01-03 at 06:10, Lowell Filak wrote:
> > The only thing I can seem to locate right now is the shell built-in command ulimit/unlimit .
> > Possibly the shell that the cgi is being run in needs unlimit set.?
> > All this is assuming that when you receive the out-of-memory error your watching top and can clearly see that there is plenty of memory left.?
> > HTH
> > Lowell F.
> > 
> > The following message was sent by "Jonathan W. Lowe" <jlowe at giswebsite.com> on 02 Jan 2003 16:34:07 -0800.
> > 
> > > List:
> > > 
> > > Perl mapscript in combination with the perl XBase and CGI modules works
> > > very well in my Redhat 8 development environment, but when moving the
> > > code to the production FreeBSD environment, the following problem
> > > results:
> > > 
> > > A program containing the statements...
> > > 
> > > 	use mapscript;
> > > 	use XBase;
> > > 
> > > ...runs the mapscript portions correctly when just the "use XBase;" line
> > > is commented out.
> > > 
> > > The same program runs the XBase portions correctly when just the "use
> > > mapscript;" line is commented out.
> > > 
> > > The line causing problems when both modules are running contains the
> > > following  perl mapscript command:
> > > 
> > > 	my $img = $map->draw() or die('Unable to draw map');
> > > 
> > > The resulting line in the apache error_log reads:
> > > 
> > > 	Out of memory!
> > > 	[Thu Jan  2 16:09:25 2003] [error] Premature end of script
> > > headers...etc
> > > 
> > > The only posting referring to "Out of memory" in this context refers to
> > > SWIG and is a couple of years old.
> > > 
> > > Any ideas for resolving this problem?
> > > 
> > > Regards,
> > > Jonathan W. Lowe
> > > 
> > > _______________________________________________
> > > Mapserver-users mailing list
> > > Mapserver-users at lists.gis.umn.edu
> > > http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> > 
> > 
> 
> 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users




More information about the mapserver-users mailing list