By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,441 Members | 1,831 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,441 IT Pros & Developers. It's quick & easy.

Memory allocation question with NuSOAP and XML parsing

P: n/a
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

Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
JAS
Mark C wrote:
Exp $. I am running PHP version 4.2.2 on RedHat 9.0


Why such an old PHP version ?

J
Jul 17 '05 #2

P: n/a
I haven't had any reason to update it, yet.
"JAS" <du*************@gmail.com> wrote in message
news:41**********@newspeer2.tds.net...
Mark C wrote:
Exp $. I am running PHP version 4.2.2 on RedHat 9.0


Why such an old PHP version ?

J

Jul 17 '05 #3

P: n/a
Am I wrong thinking you should just increase the memory_limit setting in
php.ini from the default 8M to something bigger ?

HTH
Pjotr
Jul 17 '05 #4

P: n/a
I could do that but that seems like hiding the real problem. If I have to I
have considered that option.

Mark
"Pjotr Wedersteers" <pj***@wedersteers.com> wrote in message
news:41***********************@news.xs4all.nl...
Am I wrong thinking you should just increase the memory_limit setting in
php.ini from the default 8M to something bigger ?

HTH
Pjotr

Jul 17 '05 #5

P: n/a
Mark C wrote:
I could do that but that seems like hiding the real problem. If I
have to I have considered that option.

Mark


Could be indeed. Did you debug the script and check the sizes of all the
objects created/instantiated during loop ? I did not study your example in
detail, so not sure whether you really leak memory at some point or just
have a lot of data during the process.
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.