2012-07-14 76 views
0

我正在使用捲曲下載大文件,但我不認爲緩衝區已被清空,因爲ram里程不斷增加,直到達到100%,這裏是我使用的代碼。在捲曲調用後清空內存

如果我關閉並打開卷曲會有幫助?

$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); 
+0

也許我錯過了一些重要的東西,但什麼是你想用** **很長的循環中如此多的捲曲要求?用cURL執行DDoS攻擊? – brezanac 2012-07-14 16:47:58

+0

不是所有的人,我說它在第一句話,我試圖下載大文件 – EGN 2012-07-14 17:27:22

回答

2
curl_close(), takes a Curl resource as its only parameter, 
closes the Curl session, then frees up the associated memory. 
+0

所以你說我必須每次關閉卷曲並重新打開它? – EGN 2012-07-14 16:47:53