0

我正在使用 curl 下载大文件,但我认为缓冲区没有被清空,因为 ram 里程一直在增加,直到达到 100%,这是我使用的代码。

如果我关闭并打开 curl 会有帮助吗?

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

while($start_range <= $end_range) {
if(($start_range + 999999) > $end_range) $range = $start_range.'-';
else $range = $start_range.'-'.($start_range + 999999);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $url);

curl_setopt($ch,CURLOPT_HTTPHEADER,array("ETag: $rddash"));
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_RANGE,$range);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');
if ($tmp = curl_exec($ch))  $start_range +=1000000;
echo $tmp;
flush();
} 
curl_close($ch);
4

1 回答 1

2
curl_close(), takes a Curl resource as its only parameter,   
closes the Curl session, then frees up the associated memory.
于 2012-07-14T16:40:09.160 回答