Hi all,
This is the first time to post question here, hopefully experts of perl here can give me a hand, to be honest, I am kind of new to perl, and I am struggling with the "Out of memory" issue I met when running my scripts.
Could somebody pay attention to look into the below details to give some help?
Really appreciate!!!!!
Let me give deatail info:
OS: HP 3000 MPE/iX.
Note: No "out of memory" on Winxp env, on xp I can run the script with 3 hours successfully.
What does my script do:
get the input parameter from command line, send those parameters to a web service server, write the the ruturn from the webservice server to disk file,
which the ruturn is a long string.
To stress the web service server, I need to run the script for a long time, here it
is 3 hours, so ideally within the 3 housr, the script will call the web service
with many many loops.
Error:
After a few miniutes running, acutally it has run successfully with more than 100 loops, the perl got terminated by "out of memory" error.
The error was print from STDERR.
open STDERR, ">$errlog" or die "Can't dup STDERR $!";
Error message:
sometime, it is just "Out of Memory!", some time it gives like below:
Out of memory during "large" request for 135168 bytes at /PERL/PUB/lib/perl5/site_perl/5.6.0/HTTP/Message.pm line 100.
The bleow is main code of the time and loop control, also the web service invoke:
#loop for the given runnning time
my $start_G=time();
while (2>1) {
#time control
my $start = time();
$elapsetime = $start - $start_G;
if ($elapsetime >= $runtime) {
print "\nTimeout and exit!!!";
exit 1}
$Loop++;
my $loopstart = time();
print "******$now******\nNow running for Loop $Loop!!!\n\n";
&ws_call;
my $loopend = time();
print "Time taken for loop $Loop was ", ($loopend - $loopstart), " seconds.\n\n";
my $end = time();
print "Time taken for getAdvice by CheckID: $check_id was ", ($end - $start), " seconds\n\n";
my $end_G = time();
$elapsetime = $end_G - $start_G;
print "Time elapsed $elapsetime seconds\n\n";
}
sub ws_call {
my $soap =
new SOAP::LITE->proxy( $clic_preferences{SERVICE_HOST} )
->uri('http://www.xxxx')
;
my $header =
SOAP::Header->name( accountName => $client_id )
->uri('http://www.xxxx')->prefix('mi');
print "Calling getAdvice...\n";
my @params = (
SOAP::Data->name(string => $check_id),
$header
);
my $method =
SOAP::Data->name('getAdvice')
->attr( { xmlns => 'http://www.xxxx' } );
$result = $soap->call( $method => @params );
$returnvalue = $result->result;
if( $result->fault ) {
print "Error returned from server!\n";
}
if(defined $returnvalue) {
#WRITE TO File
print "\nWriting advice to file...";
open( OUT_FILE, ">$adviceFileName" )
or die "Cannot open output file $adviceFileName\n$!";
$returnvalue =~ s/\x0D//g;
print OUT_FILE $returnvalue;
#END OF WRITE
$countPass++;
} else
{
print "\n\nNo return value!\n";
}
}#end ws_call