I have a memory allocation problem in PHP using NuSOAP and the built in XML
parser. The code below is called in a loop and executed about 1900 times
before it failed. I am using nusoap.php,v 1.76 2004/06/25 13:17:56 snichol
Exp $. I am running PHP version 4.2.2 on RedHat 9.0
I presume I need to unallocated something other than the soapclient, but I'm
nor sure what. This is the code that is called in the loop and the error
message is below. I only needed it to execute another 240 times, but my
data set will continue to grow and the total times this may need to execute
in the future will grow.
Sorry for the large post, but I wanted to show as much as I thought would be
required to provide guidance.
Thank you,
Mark C
================================================== ==========================
=
// Define new object and specify location of wsdl file.
$soapclient = new
soapclient('http://weather.gov/forecasts/xml/SOAP_server/ndfdXMLserver.php')
;
// Output any error conditions from creating the client
$err = $soapclient->getError();
if ($err)
return 0;
// call the method and get the result.
$result =
$soapclient->call('NDFDgen',$parameters,'uri:DWMLgen','uri:DWM Lgen/NDFDgen')
;
// Processes any SOAP fault information we get back from the server
if ($soapclient->fault)
return 0;
// Capture any client errors
$err = $soapclient->getError();
if ($err)
return 0;
// Parse the resulting XML from the SOAP service ($result)
$xmlParser = createParser();
setOptions($xmlParser);
setHandlers($xmlParser);
parse($xmlParser, $result);
freeParser($xmlParser);
unset($soapclient); // Unallocate object
.....
function createParser()
{
$xmlParser = xml_parser_create();
if ($xmlParser == false)
{
die('Cannot create an XML parser handle.');
}
return $xmlParser;
}
function setOptions($xmlParser)
{
xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, false);
}
function setHandlers($xmlParser)
{
xml_set_element_handler($xmlParser, 'handleBeginTag', 'handleEndTag');
xml_set_character_data_handler($xmlParser, 'HandleCharacterData');
}
function parse($xmlParser, $xmlOut)
{
$parsedOkay = xml_parse($xmlParser, $xmlOut);
if ( ! $paredOkay && xml_get_error_code($xmlParser) != XML_ERROR_NONE)
{
die('xmlParse error: ' . xml_error_string(xml_get_erro_code($xmlParser)) .
' at line ' . xml_get_current_line_number($xmlParser));
}
}
function freeParser($xmlParser)
{
$freeOkay = xml_parser_free($xmlParser);
if( ! $freeOkay)
{
die('You did not pass a proper XML pareser to this function.');
}
}
================================================== ==========================
[mark@www v2]$ time php SanityCheck.php
X-Powered-By: PHP/4.2.2
Content-type: text/html
<br />
<b>Fatal error</b>: Allowed memory size of 8388608 bytes exhausted (tried
to al
locate 9007 bytes) in <b>/usr/share/SOAP/nusoap.php</b> on line
<b>5023</b><br /
real 33m22.071s
user 6m56.890s
sys 0m2.800s