When I use the call() method of the SoapClient class in loop it seems to be building up memory.
I have tried to search for solutions on the internet and some of the answers are to disable WSDL Cache, but it did not work for me.
I have tried disabling cache with ini_set("soap.wsdl_cache_enabled", 0)
and as a parameter of the SoapClient class instance. I have tried ini_set("soap.wsdl_cache_ttl", 0)
. I also have tried unset($this->_client)
and unset($this->_session).
Nothing worked for me.
ini_set("soap.wsdl_cache_enabled", WSDL_CACHE_NONE);
private function _call($method, $params = null)
{
if (is_null($this->_client)) {
$soapParams = array(
'cache_wsdl' => WSDL_CACHE_NONE
);
$this->_client = new SoapClient($this->_getConfig('api/url'), $soapParams);
$this->_session = $this->_client->login($this->_getConfig('api/user'), $this->_getConfig('api/key'));
}
$memoryBefore = memory_get_usage();
echo "\n" . 'Memory Usage Before: ' . number_format($memoryBefore, null, '', '.');
$result = $this->_client->call($this->_session, $method, $params);
$memoryAfter = memory_get_usage();
echo "\n" . 'Memory Usage After: ' . number_format($memoryAfter, null, '', '.');
echo "\n" . 'Memory Usage Difference: ' . number_format($memoryAfter - $memoryBefore, null, '', '.') . "\n";
return $result;
}
Is there any way to solve that? Am I doing something wrong?
I'm running the following method via the command line (using PHP 5.3.29)
$ php -f datasync.php
Memory Usage Before: 13.244.400
Memory Usage After: 20.239.488
Memory Usage Difference: 6.995.088
Importing Orders...
1% [100/6055] - Page number (pagenum): 1 Page size (pagesize): 100 Total pages: 61
Memory Usage Before: 22.402.792
Memory Usage After: 29.519.432
Memory Usage Difference: 7.116.640
3% [200/6055] - Page number (pagenum): 2 Page size (pagesize): 100 Total pages: 61
Memory Usage Before: 29.519.984
Memory Usage After: 36.515.112
Memory Usage Difference: 6.995.128
4% [300/6055] - Page number (pagenum): 3 Page size (pagesize): 100 Total pages: 61
Memory Usage Before: 36.515.680
Memory Usage After: 43.723.440
Memory Usage Difference: 7.207.760
6% [400/6055] - Page number (pagenum): 4 Page size (pagesize): 100 Total pages: 61
Memory Usage Before: 43.724.056
Memory Usage After: 50.879.592
Memory Usage Difference: 7.155.536
8% [500/6055] - Page number (pagenum): 5 Page size (pagesize): 100 Total pages: 61
Memory Usage Before: 50.880.096
Memory Usage After: 58.083.616
Memory Usage Difference: 7.203.520
9% [600/6055] - Page number (pagenum): 6 Page size (pagesize): 100 Total pages: 61
Memory Usage Before: 58.084.232
Memory Usage After: 65.167.136
Memory Usage Difference: 7.082.904
11% [700/6055] - Page number (pagenum): 7 Page size (pagesize): 100 Total pages: 61