Memory allocation question with NuSOAP and XML parsing

From: Mark C (markremove_at_casazzaremove.net)
Date: 11/06/04


Date: Sat, 06 Nov 2004 20:37:00 GMT

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: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($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



Relevant Pages

  • Memory allocation question with NuSOAP and XML parsing
    ... I have a memory allocation problem in PHP using NuSOAP and the built in XML ... The code below is called in a loop and executed about 1900 times ... I only needed it to execute another 240 times, ... die('Cannot create an XML parser handle.'); ...
    (comp.lang.php)
  • Re: Is it safe to open a text file in Internet Explorer?
    ... "Download it to your disk, change the extension, then Send To ... an .xml extension you get "The XML page cannot be displayed."." ... I've read, re-read, Googled, and MSN searched -- MSN search is ... way that this can actually execute anything. ...
    (microsoft.public.security)
  • Safe multithreading in ASP.Net
    ... Code in global.asx Application_start subroutine, ... Dim emails As New ForumEmail ... Do While ContinueNotify 'boolean value set to True so loop will continue ... the thread still continues to execute. ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: What is the difference between for..if, case statements, do..while
    ... ElseIf Then ... It can not execute both This and That or any ... Loop Until ... How does one decide which programming construct to use. ...
    (microsoft.public.excel.programming)
  • Re: What is the difference between for..if, case statements, do..while
    ... ElseIf Then ... It can not execute both This and That or any ... Loop Until ... Do while an loop until cause you to loop throgh the same st of instructions ...
    (microsoft.public.excel.programming)