Annotation of embedaddon/php/ext/standard/tests/streams/bug61371.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Bug #61371: stream_context_create() causes memory leaks on use streams_socket_create
        !             3: --FILE--
        !             4: <?php
        !             5: function test($doFclose) {
        !             6: $previous = null;
        !             7: $current = null;
        !             8: for($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://0.0.0.0: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: 
        !            27: test(true);
        !            28: test(false);
        !            29: ?>
        !            30: --EXPECTF--
        !            31: memory: %dkb
        !            32: bool(true)
        !            33: memory: %dkb
        !            34: bool(true)
        !            35: memory: %dkb
        !            36: memory: %dkb
        !            37: bool(true)
        !            38: memory: %dkb
        !            39: bool(true)
        !            40: memory: %dkb

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>