Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

nusoap

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?

like image 707
Alexey Choporov Avatar asked Nov 22 '12 10:11

Alexey Choporov


People also ask

How do I fix the allowed memory size 134217728 bytes exhausted?

The correct way is to edit your php. ini file. Edit memory_limit to your desire value. As from your question, 128M (which is the default limit) has been exceeded, so there is something seriously wrong with your code as it should not take that much.

How do I fix the allowed memory size 1610612736 bytes exhausted?

Allowed memory size of 1610612736 bytes exhausted ??? can someone help me this? Try prefixing your command with COMPOSER_MEMORY_LIMIT=-1 . This will remove the memory limit for the execution of the command.


1 Answers

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.

like image 189
Miklos Krivan Avatar answered Nov 09 '22 12:11

Miklos Krivan