- memory_get_usage: documentation ( source)
- implode: documentation ( source)
- printf: documentation ( source)
<?php
class Foo {
function __construct()
{
$this->bar = new Bar($this);
}
}
class Bar {
function __construct($foo = null)
{
$this->foo = $foo;
}
}
$usage = 0;
$maxima = array();
while (count($maxima) < 5 && $usage < 50000000) {
$foo = new Foo();
unset($foo);
$last = $usage;
$usage = memory_get_usage();
if ($usage < $last) {
$maxima[] = $last;
}
}
if (count($maxima)) {
printf("Not buggy: Maxima: %s\n", implode('; ', $maxima));
} else {
printf("Buggy! Memory never went down.");
}
?>