我用我的腳本這個API(https://api.ssactivewear.com/v2/products/):內存分配問題後,增加內存限制
ini_set('memory_limit', "300M");
$uri=$end_url.$method;
$ch = curl_init($uri);
$access_key=base64_encode($customer_number.':'.$api_key);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Basic ' . $access_key));
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$retrive_response = curl_exec($ch);
curl_close($ch);
return $retrive_response;
腳本的幾個時間執行後,我收到一個錯誤
Fatal error: Allowed memory size of 314572800 bytes exhausted (tried to allocate 161956814 bytes)
您可以通過使用'echo ini_get(「memory_limit」)來檢查內存限制是否實際增加了。看到相關的帖子http://stackoverflow.com/questions/5061917/ini-setmemory-limit-in-php-5-3-3-is-not-working-at-all 還要確保它在腳本的頂部,並記住增加只針對正在運行的腳本 –