xref: /PHP-5.6/Zend/tests/bug43450.phpt (revision 42f94aa9)
1--TEST--
2Bug #43450 (Memory leak on some functions with implicit object __toString() call)
3--SKIPIF--
4<?php if (!function_exists('memory_get_usage')) die('memory_get_usage() not installed'); ?>
5--INI--
6opcache.enable_cli=0
7--FILE--
8<?php
9error_reporting(E_ALL|E_STRICT);
10
11class Foo
12{
13    public function __toString()
14	{
15	    return __CLASS__;
16	}
17}
18
19$num_repeats = 100000;
20
21$start = (memory_get_usage() / 1024) + 16;
22for ($i=1;$i<$num_repeats;$i++)
23{
24	$foo = new Foo();
25	md5($foo);
26}
27$end = memory_get_peak_usage() / 1024;
28
29if ($start < $end) {
30	echo 'FAIL';
31} else {
32	echo 'PASS';
33}
34
35?>
36--EXPECT--
37PASS
38