我用我的脚本这个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 还要确保它在脚本的顶部,并记住增加只针对正在运行的脚本 –