1--TEST-- 2Bug #45161 (Reusing a curl handle leaks memory) 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) == 'WIN') { 6 exit("skip not for Windows"); 7} 8if (!extension_loaded("curl")) { 9 exit("skip curl extension not loaded"); 10} 11$curl_version = curl_version(); 12if ($curl_version['version_number'] < 0x071100) { 13 exit("skip: test works only with curl >= 7.17.0"); 14} 15?> 16--FILE-- 17<?php 18 19// Fill memory for test 20$ch = curl_init(); 21$fp = fopen('/dev/null', 'w'); 22 23/* 24$i = $start = $end = 100000.00; 25for ($i = 0; $i < 100; $i++) { 26 curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:9/'); 27 curl_setopt($ch, CURLOPT_FILE, $fp); 28 curl_exec($ch); 29} 30*/ 31 32// Start actual test 33$start = memory_get_usage() + 1024; 34for($i = 0; $i < 1024; $i++) { 35 curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:9/'); 36 curl_setopt($ch, CURLOPT_FILE, $fp); 37 curl_exec($ch); 38} 39if ($start < memory_get_usage()) { 40 echo 'FAIL'; 41} else { 42 echo 'PASS'; 43} 44echo "\n"; 45fclose($fp); 46unset($fp); 47?> 48--EXPECT-- 49PASS 50