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('htt p://weather.gov/forecasts/xml/SOAP_server/ndfdXMLserver.p hp')
;
// 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,'u ri:DWMLgen','ur i:DWMLgen/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($xml Parser);
setHandlers($xm lParser);
parse($xmlParse r, $result);
freeParser($xml Parser);
unset($soapclie nt); // Unallocate object
.....
function createParser()
{
$xmlParser = xml_parser_crea te();
if ($xmlParser == false)
{
die('Cannot create an XML parser handle.');
}
return $xmlParser;
}
function setOptions($xml Parser)
{
xml_parser_set_ option($xmlPars er, XML_OPTION_CASE _FOLDING, false);
}
function setHandlers($xm lParser)
{
xml_set_element _handler($xmlPa rser, 'handleBeginTag ', 'handleEndTag') ;
xml_set_charact er_data_handler ($xmlParser, 'HandleCharacte rData');
}
function parse($xmlParse r, $xmlOut)
{
$parsedOkay = xml_parse($xmlP arser, $xmlOut);
if ( ! $paredOkay && xml_get_error_c ode($xmlParser) != XML_ERROR_NONE)
{
die('xmlParse error: ' . xml_error_strin g(xml_get_erro_ code($xmlParser )) .
' at line ' . xml_get_current _line_number($x mlParser));
}
}
function freeParser($xml Parser)
{
$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