xref: /PHP-5.3/Zend/tests/bug43450.phpt (revision 1b6100f4)
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--FILE--
6<?php
7error_reporting(E_ALL|E_STRICT);
8
9class Foo
10{
11    public function __toString()
12	{
13	    return __CLASS__;
14	}
15}
16
17$num_repeats = 100000;
18
19$start = (memory_get_usage() / 1024) + 16;
20for ($i=1;$i<$num_repeats;$i++)
21{
22	$foo = new Foo();
23	md5($foo);
24}
25$end = memory_get_peak_usage() / 1024;
26
27if ($start < $end) {
28	echo 'FAIL';
29} else {
30	echo 'PASS';
31}
32
33?>
34--EXPECT--
35PASS
36