in reply to Re2: Possible Server Resources problem
in thread Possible Server Resources problem
I doubt that I'm even approaching 10MB of memory - if one can go by the filesize * nº files 'required' etc...at least as a stating point?!?
You can't make that assumption at all. Hello World in Perl takes over 1MB although it is obviously only one line of Perl. I can use *all* your systems resources with just one 12 char line of perl. Perl is a memory pig in many ways. This reflects the optimisation strategy of spending memory to gain speed.
Re: debuging - I have included a &my_err() sub to sort-of 'trap' errors, but only for opening files and requiring files, nothing else. However, it certainly does the job.
You are totally missing the point. You need to see where your code gets to, so you add the debugging as suggested to do that. BTW you dont need the & if you call function().
$DEBUG=1; $DEBUG && warn "Doing foo!\n"; foo(); $DEBUG && warn "Done foo!\n"; #etc
The whole thing just freezes!
It most certainly does not. You just don't know where it stops which is somewhere between starting and completing :-) That is why you need the debugging flow messages. The messages appear in the error log. See CGI Help Guide
So, apart from using a debug sub and following the 'flow' of data by putting "Ooh look! I managed to get this far" in the script, is there anything else I might be able to try or am I destined to go thru 1,000's of lines of code, doing CTRL-V and getting my script to go "Boo!" on-screen?!?
You don't seem to get it. You *need* to add the debug code. If the $DEBUG is set it writes messages to the error log for you to review. If $DEBUG=0 it does nothing. The code runs as usual. Thus you can put the code in and leave it. You don't even know where your code gets to, so you have no idea what the problem is. I have not seen your code, nor do I want to. All I can offer is the logic used by millions of programmers across the world. Don't speculate. Isolate the problem first, then fix it.
But there is a shortcut of sorts. If you don't mind going through reams of output then install Devel::Trace. In your cgi activate it as shown. Every *line* that is executed will then generate a logging message in the error logs.
#!/usr/bin/perl -d:Trace Devel::Trace::trace('on'); # Enable print "Hello World\n"; foo(); Devel::Trace::trace('off'); # Disable foo(); sub foo{ print "Foo\n" }
Make sure this sample runs first, then just add -d:Trace to the shebang +/- Disable/Enable it in sections. Here is what happens when I run that and redirect stderr to a file.
C:\>test.pl 2>out Hello World Foo Foo
So there is all the expected output, no more no less. Situation normal....but if we look in file 'out' (this will automatically be error_log with a CGI) we have a complete stack trace:
C:\>more out >> C:\test.pl:3: Devel::Trace::trace('on'); # Enable >> D:/Perl/site/lib/Devel/Trace.pm:31: my $arg = shift; >> D:/Perl/site/lib/Devel/Trace.pm:32: $arg = $tracearg{$arg} while +exists $tracearg{$arg}; >> D:/Perl/site/lib/Devel/Trace.pm:33: $TRACE = $arg; >> C:\test.pl:5: print "Hello World\n"; >> C:\test.pl:7: foo(); >> C:\test.pl:13: sub foo{ print "Foo\n" } >> C:\test.pl:9: Devel::Trace::trace('off'); # Disable >> D:/Perl/site/lib/Devel/Trace.pm:31: my $arg = shift; >> D:/Perl/site/lib/Devel/Trace.pm:32: $arg = $tracearg{$arg} while +exists $tracearg{$arg}; >> D:/Perl/site/lib/Devel/Trace.pm:33: $TRACE = $arg; C:\>
cheers
tachyon
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Re2: Possible Server Resources problem
by meetn2veg (Scribe) on Sep 10, 2004 at 13:50 UTC |