Jim Turner wrote:
> 
> Greetings,
> 
>         I am using Apache 1.3.9 on Linux kernel 2.0.36 using
> ApacheASP wrapped around my CGI scripts.  I have the following
> test script which works fine unless I declare the array variable
> "v" as "my @v".  This causes massive memory consumption in that
> much more memory is allocated each time the script is run, even
> though only 2 instances are actually run.  If "v" is NOT declared
> as "my", it seems to work fine (1st 2 invocations load up and
> scarf up memory, but after that, things run fine).  Can anyone
> tell me why this is?
> 

I'm not sure why in this case as your code below 
looks fine.  I would advise though that you move
your subroutine into a perl module or your 
global.asa, as subroutines in ASP scripts can
be tricky because an ASP script itself is compiled
as a subroutine, and variable scoping problems 
can result.  See my closure problems in the
modperl guide http://perl.apache.org/guide
which Apache::ASP shares with Apache::Registry.

> ----------------------------------------------
> Here is my ASP file:
> ----------------------------------------------
> <%
> 
> <!--#include file=test-->
> 
> %>

BTW, this use of the include mechanism was never
intended to work by me, and am well impressed that you 
came up with another use!  Beautiful.  More below.

> ----------------------------------------------
> Here is my test script (runs as CGI, FAST-CGI, and ASP):
> ----------------------------------------------
> #!/usr/bin/perl
> 
> if ($0 =~ /\.asp/i)
> {
>         $runtype = 2;  #RUNNING AS ASP!
> }
> elsif ($0 =~ /\.fpl/i)
> {
>         $runtype = 1;  #RUNNING AS FAST-CGI!
> }
> else
> {
>         $runtype = 0;  #RUNNING AS REGULAR CGI!
> }
> 
> require 'global.asa';
> 

You only need to require global.asa if you are
not running as an ASP script, as Apache::ASP 
effectively does this for you.

BTW, it looks like you are setting up a benchmarking
testbed on your server.  I would be interested 
in how you find FastCGI to perform against 
Apache::ASP.  If you are up for running the hello world
tests, you can add some data to what we have at
  http://www.chamas.com/bench/

Note one of the advantages of Apache::ASP is its
rich object API, which incurs some overhead setting
up, so there is an ease of development vs. performance 
trade-off here.  You will find for example that 
Apache::Registry scripts run CGIs faster than
Apache::ASP will because of this overhead.  If you 
just want CGI emulation, I would stick with Registry.

--Joshua

> srand($$);
> my ($randpid) = $$;
> 
> $mainloop = 0;
> mainloop:  while ($runtype != 1 || new CGI::Fast)
> {
>         last  if ($mainloop && $runtype != 1);
>         ++$mainloop;
>         ++$runcnt;
>         $randpid = int(rand(9999));
>         &Home();
> }
> 
> sub Home
> {
>         print &CGI::header()  unless (shift);
> 
> print "<BR>PID=$$= rc=$runcnt=\n";
>         my @v = ();
>         for (my $i=0;$i<=150000;$i++)
>         {
>                 push (@v, $i);
>         }
> print "<BR>1st=$v[0]= last=$v[150000]=\n";
> }
> 
> ----------------------------------------------
> Here is my global.asa
> ----------------------------------------------
> use CGI::Fast qw(:standard);
> use CGI qw(:standard);
> 
> sub Application_OnStart
> {
> }
> 
> 1;
> ----------------------------------------------
>

Reply via email to