Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

varDump is causing out of memory

Anonymous
2011-02-28
2013-06-06

  • Anonymous
    2011-02-28

    We have a soap link to a document server which cannot deliver documents bigger then around 20 MB

    We get PHP Fatal error:  Allowed memory size

    [Mon Feb 28 14:54:00 2011] [error] [client 127.0.0.1] PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 87193601 bytes) in .../path-to-nusoap/libraries/nusoap/nusoap.php on line 875
    
    [Mon Feb 28 14:54:00 2011] [error] [client 127.0.0.1] PHP   8. nusoap_client->send() .../path-to-nusoap/libraries/nusoap/nusoap.php:7448
    [Mon Feb 28 14:54:00 2011] [error] [client 127.0.0.1] PHP   9. nusoap_client->parseResponse() .../path-to-nusoap/libraries/nusoap/nusoap.php:7633
    [Mon Feb 28 14:54:00 2011] [error] [client 127.0.0.1] PHP  10. nusoap_parser->nusoap_parser() .../path-to-nusoap/libraries/nusoap/nusoap.php:7676
    [Mon Feb 28 14:54:00 2011] [error] [client 127.0.0.1] PHP  11. nusoap_base->varDump() .../path-to-nusoap/libraries/nusoap/nusoap.php:6634
    [Mon Feb 28 14:54:00 2011] [error] [client 127.0.0.1] PHP  12. var_dump() .../path-to-nusoap/libraries/nusoap/nusoap.php:875
    

    A solution is to check for getDebugLevel() when either varDump or skip calls to varDump.

    My code changes are in nusoap_client creating a new nusoap_parser

    Add options to constructor

    function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true, $options = array()){
    

    Respect the settings

    if (isset($options['debugLevel'])) $this->setDebugLevel($options['debugLevel']);
    
    if ($this->debugLevel>0) $this->appendDebug($this->varDump($this->message));
    

    Then make sure the callee pass the settings like this (which I only did for nusoap_client)

    $options['debugLevel'] = $this->getDebugLevel();
    $parser = new nusoap_parser($data,$this->xml_encoding,$this->operation,$this->decode_utf8, $options);
    

    I don't have a patch right now due to dos versus windows file diff and because the above is not complete.