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?>
9--FILE--
10<?php
11function test($doFclose) {
12$previous = null;
13$current = null;
14for($test=1;$test<=3;$test++) {
15    $current = memory_get_usage(true);
16    if (!is_null($previous)) {
17        var_dump($previous == $current);
18    }
19    $previous = $current;
20    echo 'memory: '.round($current / 1024, 0)."kb\n";
21    for($i=0;$i<=100;$i++) {
22        $context = stream_context_create(array());
23        $stream = stream_socket_client('udp://0.0.0.0:80', $errno, $errstr, 10, STREAM_CLIENT_CONNECT, $context);
24        if ($doFclose) fclose($stream);
25        unset($context);
26        unset($stream);
27        unset($errno);
28        unset($errstr);
29    }
30}
31}
32
33test(true);
34test(false);
35?>
36--EXPECTF--
37memory: %dkb
38bool(true)
39memory: %dkb
40bool(true)
41memory: %dkb
42memory: %dkb
43bool(true)
44memory: %dkb
45bool(true)
46memory: %dkb
47