1--TEST--
2Bug #61371: stream_context_create() causes memory leaks on use streams_socket_create
3--SKIPIF--
4<?php
5if(substr(PHP_OS, 0, 3) == 'WIN' ) {
6	die('skip non windows test');
7}
8--FILE--
9<?php
10function test($doFclose) {
11$previous = null;
12$current = null;
13for($test=1;$test<=3;$test++) {
14	$current = memory_get_usage(true);
15	if (!is_null($previous)) {
16		var_dump($previous == $current);
17	}
18	$previous = $current;
19	echo 'memory: '.round($current / 1024, 0)."kb\n";
20	for($i=0;$i<=100;$i++) {
21		$context = stream_context_create(array());
22		$stream = stream_socket_client('udp://0.0.0.0:80', $errno, $errstr, 10, STREAM_CLIENT_CONNECT, $context);
23		if ($doFclose) fclose($stream);
24		unset($context);
25		unset($stream);
26		unset($errno);
27		unset($errstr);
28	}
29}
30}
31
32test(true);
33test(false);
34?>
35--EXPECTF--
36memory: %dkb
37bool(true)
38memory: %dkb
39bool(true)
40memory: %dkb
41memory: %dkb
42bool(true)
43memory: %dkb
44bool(true)
45memory: %dkb
46