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