- memory_get_peak_usage: documentation ( source)
<?php
class Foo {
private $orig;
public function bar() {
$this->orig = clone $this;
}
}
$foo = new Foo;
for ($i = 0; $i < 20; $i++) {
$foo->bar();
echo (memory_get_peak_usage(true) / 1024 / 1024) . "\n";
}