Search code examples
phpnusoap

NuSOAP varDump PHP Fatal error: Allowed memory size of 134217728 bytes exhausted


Sorry for my english :)

I have NuSOAP version 0.9.5. And I have had an php error when tried to get a big data:

PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 27255652 bytes)

Stack trace shows that problem was in varDump method.

My solution is:

I have changed varDump method (in nusoap.php) to:

function varDump($data) {
    $ret_val = "";
    if ($this->debugLevel > 0) {
        ob_start();
        var_dump($data);
        $ret_val = ob_get_contents();
        ob_end_clean();
    }
    return $ret_val; 
}

and then reset

$GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']

to 0 (from 9). In class.nusoap_base.php and nusoap.php.

This helped me.

Does anyone have any comments on this? Or maybe better solution?


Solution

  • Many thanks and respect to Aaron Mingle for the real solution found for NuSOAP out of memory problem. The solution can be found here:

    https://sourceforge.net/p/nusoap/discussion/193578/thread/12965595/

    I already implemented and immediately tested and I am happy now because it works perfect. In my case I had approx 45 MB SOAP message size (including ~30 pdf files in base64 encoded) and even 2 GB memory for PHP did not helped before. So I have tried Aaron Mingle's solution and it was the good solution with only 384 MB memory granted to PHP.

    +1 to Alexey Choporov as well because his suggestion is also required. So both modification is a must have patch in NuSOAP working preperly with larger messages.